summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-29 22:00:51 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-29 22:00:51 +0000
commit8a9600ded15d1846c9e38de0b660a0f6a72e20a9 (patch)
tree2f580058851d7028bef31d2c570aa62c1f955141
parent9d6ca2f45f252753ae27650565dd3728f14d3bf3 (diff)
downloadhercules-8a9600ded15d1846c9e38de0b660a0f6a72e20a9.tar.gz
hercules-8a9600ded15d1846c9e38de0b660a0f6a72e20a9.tar.bz2
hercules-8a9600ded15d1846c9e38de0b660a0f6a72e20a9.tar.xz
hercules-8a9600ded15d1846c9e38de0b660a0f6a72e20a9.zip
- Corrected the homunculus deletion functions so that the homunculus is deleted together with the character.
- Added npc_check_areanpc so that Wand of Hermod will correctly check for nearby warps. - Emergency avoid now stacks with other speed boost statuses - Item skills and skills that bring up a menu now are cleared on death. - Minor cleanings git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9742 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt7
-rw-r--r--src/char_sql/char.c9
-rw-r--r--src/char_sql/int_homun.c24
-rw-r--r--src/char_sql/int_homun.h1
-rw-r--r--src/map/mob.c4
-rw-r--r--src/map/npc.c69
-rw-r--r--src/map/npc.h1
-rw-r--r--src/map/pc.c6
-rw-r--r--src/map/skill.c3
-rw-r--r--src/map/status.c7
10 files changed, 110 insertions, 21 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 9c8d45b60..41a39e39d 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,13 @@ 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.
2007/01/29
+ * Corrected the homunculus deletion functions so that the homunculus is
+ deleted together with the character.
+ * Added npc_check_areanpc so that Wand of Hermod will correctly check for
+ nearby warps.
+ * Emergency avoid now stacks with other speed boost statuses
+ * Item skills and skills that bring up a menu now are cleared on death.
+ [Skotlex]
* Added a nasty hack to prevent multilanguage clients from breaking guild notices
2007/01/27
* Made @reloadscript wipe ALL previous mobs that the script engine spawned
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 4c1358312..ea34d9b10 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -1455,9 +1455,9 @@ int make_new_char_sql(int fd, unsigned char *dat) {
int delete_char_sql(int char_id, int partner_id)
{
char char_name[NAME_LENGTH], t_name[NAME_LENGTH*2]; //Name needs be escaped.
- int account_id=0, party_id=0, guild_id=0, char_base_level=0;
+ int account_id, party_id, guild_id, hom_id, char_base_level;
- sprintf(tmp_sql, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level` FROM `%s` WHERE `char_id`='%d'",char_db, char_id);
+ sprintf(tmp_sql, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`hom_id` FROM `%s` WHERE `char_id`='%d'",char_db, char_id);
if (mysql_query(&mysql_handle, tmp_sql)) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
@@ -1483,6 +1483,7 @@ int delete_char_sql(int char_id, int partner_id)
party_id = atoi(sql_row[2]);
guild_id = atoi(sql_row[3]);
char_base_level = atoi(sql_row[4]);
+ hom_id = atoi(sql_row[5]);
mysql_free_result(sql_res); //Let's free this as soon as possible to avoid problems later on.
//check for config char del condition [Lupus]
@@ -1545,6 +1546,10 @@ int delete_char_sql(int char_id, int partner_id)
}
}
+ /* remove homunculus */
+ if (hom_id)
+ inter_delete_homunculus(hom_id);
+
/* delete char's friends list */
sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id` = '%d'",friend_db, char_id);
if(mysql_query(&mysql_handle, tmp_sql)) {
diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c
index 3fc0ca8a4..427559d30 100644
--- a/src/char_sql/int_homun.c
+++ b/src/char_sql/int_homun.c
@@ -212,27 +212,33 @@ int mapif_load_homunculus(int fd){
return mapif_info_homunculus(fd, RFIFOL(fd,2), homun_pt);
}
-
-
-int mapif_delete_homunculus(int fd)
+int inter_delete_homunculus(int hom_id)
{
- RFIFOHEAD(fd);
- sprintf(tmp_sql, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", RFIFOL(fd,2));
+ sprintf(tmp_sql, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", hom_id);
if(mysql_query(&mysql_handle, tmp_sql))
{
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- return mapif_homunculus_deleted(fd, 0);
+ mapif_homunculus_deleted(fd, 0);
+ return 0;
}
- sprintf(tmp_sql, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", RFIFOL(fd,2));
+ sprintf(tmp_sql, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", hom_id);
if(mysql_query(&mysql_handle, tmp_sql))
{
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- return mapif_homunculus_deleted(fd, 0);
+ mapif_homunculus_deleted(fd, 0);
+ return 0;
}
- return mapif_homunculus_deleted(fd, 1);
+ mapif_homunculus_deleted(fd, 1);
+ return 1;
+}
+
+int mapif_delete_homunculus(int fd)
+{
+ RFIFOHEAD(fd);
+ inter_delete_homunculus(RFIFOL(fd,2));
}
int mapif_rename_homun_ack(int fd, int account_id, int char_id, unsigned char flag, char *name){
diff --git a/src/char_sql/int_homun.h b/src/char_sql/int_homun.h
index cfc46ca24..2b9af8ebc 100644
--- a/src/char_sql/int_homun.h
+++ b/src/char_sql/int_homun.h
@@ -9,6 +9,7 @@ void inter_homunculus_sql_final(void);
int mapif_save_homunculus(struct s_homunculus *hd);
int mapif_load_homunculus(int fd);
int mapif_delete_homunculus(int fd);
+int inter_delete_homunculus(int hom_id);
int inter_homunculus_parse_frommap(int fd);
#endif
diff --git a/src/map/mob.c b/src/map/mob.c
index c624643ef..b4ba0be55 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1100,8 +1100,8 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
(md->ud.attacktimer == -1 && !status_check_skilluse(&md->bl, tbl, 0, 0)) ||
(md->ud.walktimer != -1 && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) ||
(
- tbl->type == BL_PC && !(mode&MD_BOSS) &&
- (((TBL_PC*)tbl)->state.gangsterparadise ||
+ tbl->type == BL_PC &&
+ ((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) ||
((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER)
)) { //Unlock current target.
if (tbl && tbl->m != md->bl.m && battle_config.mob_ai&0x40)
diff --git a/src/map/npc.c b/src/map/npc.c
index c1caa3fee..a996b2112 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1005,6 +1005,67 @@ int npc_touch_areanpc2(struct block_list *bl)
return 1;
}
+//Checks if there are any NPC on-touch objects on the given range.
+//Flag determines the type of object to check for:
+//&1: NPC Warps
+//&2: NPCs with on-touch events.
+int npc_check_areanpc(int flag,int m,int x,int y,int range)
+{
+ int i;
+ int x0,y0,y0,y1;
+ int xs,ys;
+
+ if (range < 0) return 0;
+ x0 = x-range;
+ x1 = x+range;
+ y0 = y-range;
+ y1 = y+range;
+
+ //First check for npc_cells on the range given
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 >= map[m].xs) x1 = map[m].xs-1;
+ if (y1 >= map[m].ys) y1 = map[m].ys-1;
+ i = 0;
+ for (ys = y0; ys <= y1 && !i; ys++) {
+ for(xs = x0; xs <= x1 && !i; xs++){
+ if (map_getcell(m,xs,ys,CELL_CHKNPC))
+ i = 1;
+ }
+ }
+ if (!i) return 0; //No NPC_CELLs.
+
+ //Now check for the actual NPC on said range.
+ for(i=0;i<map[m].npc_num;i++) {
+ if (map[m].npc[i]->sc.option&OPTION_INVISIBLE)
+ continue;
+
+ switch(map[m].npc[i]->bl.subtype) {
+ case WARP:
+ if (!(flag&1))
+ continue;
+ xs=map[m].npc[i]->u.warp.xs;
+ ys=map[m].npc[i]->u.warp.ys;
+ break;
+ case SCRIPT:
+ if (!(flag&2))
+ continue;
+ xs=map[m].npc[i]->u.scr.xs;
+ ys=map[m].npc[i]->u.scr.ys;
+ break;
+ default:
+ continue;
+ }
+ if (x0 >= map[m].npc[i]->bl.x-xs/2 && x1 < map[m].npc[i]->bl.x-xs/2+xs &&
+ y0 >= map[m].npc[i]->bl.y-ys/2 && y1 < map[m].npc[i]->bl.y-ys/2+ys)
+ break;
+ }
+ if (i==map[m].npc_num)
+ return 0;
+
+ return (map[m].npc[i]->bl.id);
+}
+
/*==========================================
* 近くかどうかの判定
*------------------------------------------
@@ -1297,9 +1358,10 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list)
nd = nd->master_nd; //For OnSell triggers.
for(i=0,z=0;i<n;i++) {
- int nameid, idx, qty;
+ int nameid, idx;
+ short qty;
idx = item_list[i*2]-2;
- qty = item_list[i*2+1];
+ qty = (short)item_list[i*2+1];
if (idx <0 || idx >=MAX_INVENTORY || qty < 0)
break;
@@ -1314,7 +1376,8 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list)
else
z+=(double)qty*pc_modifysellvalue(sd,sd->inventory_data[idx]->value_sell);
- if(sd->inventory_data[idx]->type==7 && sd->status.inventory[idx].card[0] == (short)0xff00)
+ if(sd->inventory_data[idx]->type == IT_PETEGG &&
+ sd->status.inventory[idx].card[0] == CARD0_PET)
{
if(search_petDB_index(sd->status.inventory[idx].nameid, PET_EGG) >= 0)
intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1],sd->status.inventory[idx].card[2]));
diff --git a/src/map/npc.h b/src/map/npc.h
index 63772089c..2f546ae0d 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -41,6 +41,7 @@ int npc_timer_event(const unsigned char *eventname); // Added by RoVeRT
int npc_command(struct map_session_data *sd,const unsigned char *npcname,char *command);
int npc_touch_areanpc(struct map_session_data *,int,int,int);
int npc_touch_areanpc2(struct block_list *bl); // [Skotlex]
+int npc_check_areanpc(int flag,int m,int x,int y,int range);
int npc_click(struct map_session_data *sd,struct npc_data *nd);
int npc_scriptcont(struct map_session_data *,int);
TBL_NPC *npc_checknear(struct map_session_data *sd,struct block_list *bl);
diff --git a/src/map/pc.c b/src/map/pc.c
index d52303204..5d97b4587 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4874,9 +4874,15 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
}
pc_setdead(sd);
+ //Reset menu skills/item skills
+ if (sd->skillitem)
+ sd->skillitem = sd->skillitemlv = 0;
+ if (sd->menuskill_id)
+ sd->menuskill_id = sd->menuskill_lv = 0;
//Reset ticks.
sd->hp_loss_tick = sd->sp_loss_tick = 0;
+
pc_setglobalreg(sd,"PC_DIE_COUNTER",++sd->die_counter);
if (sd->state.event_death){
diff --git a/src/map/skill.c b/src/map/skill.c
index 54c66986a..7259fa6c0 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -8265,8 +8265,7 @@ int skill_check_condition (struct map_session_data *sd, int skill, int lv, int t
break;
}
case CG_HERMODE:
- if (map_foreachinrange (skill_check_condition_hermod_sub, &sd->bl,
- skill_get_splash(skill, lv), BL_NPC) < 1)
+ if(!npc_check_areanpc(1,sd->bl.m,sd->bl.x,sd->bl.y,skill_get_splash(skill, lv)))
{
clif_skill_fail(sd,skill,0,0);
return 0;
diff --git a/src/map/status.c b/src/map/status.c
index 0620b0c0f..9b228701c 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -3654,9 +3654,12 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
speed += 300;
if(sc->data[SC_GATLINGFEVER].timer==-1)
- { //% increases (they don't stack, with the exception of Speedup1? @.@)
+ { //% increases (they don't stack, with a few exception)
if(sc->data[SC_SPEEDUP1].timer!=-1)
speed -= speed * 50/100;
+ else if(sc->data[SC_AVOID].timer!=-1)
+ speed -= speed * sc->data[SC_AVOID].val2/100;
+
if(sc->data[SC_RUN].timer!=-1)
speed -= speed * 50/100;
else if(sc->data[SC_SPEEDUP0].timer!=-1)
@@ -3669,8 +3672,6 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
speed -= speed * 20/100;
else if(sc->data[SC_BERSERK].timer!=-1)
speed -= speed * 20/100;
- else if(sc->data[SC_AVOID].timer!=-1)
- speed -= speed * sc->data[SC_AVOID].val2/100;
else if(sc->data[SC_WINDWALK].timer!=-1)
speed -= speed * sc->data[SC_WINDWALK].val3/100;
}