summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index e9ddb3e53..aca127546 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1062,7 +1062,9 @@ int npc_globalmessage(const char *name,char *mes)
*/
int npc_click(struct map_session_data *sd,int id)
{
- struct npc_data *nd;
+ struct npc_data *nd = NULL;
+ TBL_MOB *md = NULL;
+ int tick = 0;
nullpo_retr(1, sd);
@@ -1072,12 +1074,42 @@ int npc_click(struct map_session_data *sd,int id)
return 1;
}
+ if(id < 0){
+ id = -id;
+ }
+
+ nd=(struct npc_data *)map_id2bl(id);
+
+ switch(nd->bl.type){
+ case BL_MOB:
+ md = ((TBL_MOB *)nd);
+ if(md->nd){
+ if(sd->bl.m == md->bl.m && distance_bl(&sd->bl, &md->bl) <= AREA_SIZE)
+ sd->npc_pos = run_script(md->nd->u.scr.script,0,sd->bl.id,id);
+ return 0;
+ }
+ case BL_PC:
+ tick = gettick();
+ if (sd->sc.option&OPTION_HIDE || sd->sc.option&OPTION_WEDDING || sd->vd.class_ == JOB_XMAS)
+ return 0;
+
+ if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
+ if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
+ clif_skill_fail(sd, 1, 4, 0);
+ return 0;
+ }
+ }
+ if (sd->invincible_timer != -1)
+ pc_delinvincibletimer(sd);
+
+ sd->idletime = tick;
+ unit_attack(&sd->bl, id, 1);
+ return 0;
+ }
if (npc_checknear(sd,id))
return 1;
- nd=(struct npc_data *)map_id2bl(id);
-
//Hidden/Disabled npc.
if (nd->class_ < 0 || nd->sc.option&OPTION_INVISIBLE)
return 1;