Преглед изворни кода

* [Improved]:
- npc_click interception on BL_MOB and BL_PC to let sd act accordingly.

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

Lance пре 19 година
родитељ
комит
b324c2e683
2 измењених фајлова са 38 додато и 3 уклоњено
  1. 3 0
      Changelog-Trunk.txt
  2. 35 3
      src/map/npc.c

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ 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/06/09
+	* [Improved]:
+	  - npc_click interception on BL_MOB and BL_PC to let sd act accordingly.
+	    [Lance]
 	* [Fixed]:
 	  - Execution of sleep/sleep2 more than once will hang the script_state.
 	    [Lance]

+ 35 - 3
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;