浏览代码

* Fixed #629. Thank @anacondaqq and @theultramage
* Added optional param `char_id` for `instance_enter`.

Signed-off-by: Cydh Ramdh <cydh@pservero.com>

Cydh Ramdh 9 年之前
父节点
当前提交
927d1e2f5c
共有 3 个文件被更改,包括 26 次插入19 次删除
  1. 3 1
      doc/script_commands.txt
  2. 12 8
      src/map/pc.c
  3. 11 10
      src/map/script.c

+ 3 - 1
doc/script_commands.txt

@@ -7838,7 +7838,7 @@ the script will come to a halt.
 
 
 ---------------------------------------
 ---------------------------------------
 
 
-*instance_enter("<instance name>"{,<x>,<y>});
+*instance_enter("<instance name>"{,<x>,<y>,<char_id>});
 
 
 Warps player to the specified instance after the script terminates. The map and
 Warps player to the specified instance after the script terminates. The map and
 coordinates are located in 'db/(pre-)re/instance_db.txt'.
 coordinates are located in 'db/(pre-)re/instance_db.txt'.
@@ -7848,6 +7848,8 @@ The command returns 0 upon success, and these values upon failure:
  2: Party does not have an instance.
  2: Party does not have an instance.
  3: Other errors (invalid instance name, instance doesn't match with party).
  3: Other errors (invalid instance name, instance doesn't match with party).
 
 
+Put -1 for x and y if want to warp player with default entrance coordinates.
+
 ---------------------------------------
 ---------------------------------------
 
 
 *instance_npcname("<npc name>"{,<instance id>})
 *instance_npcname("<npc name>"{,<instance id>})

+ 12 - 8
src/map/pc.c

@@ -5374,7 +5374,7 @@ char pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int
 	
 	
 	//check if we gonna be rewarped [lighta]
 	//check if we gonna be rewarped [lighta]
 	if(npc_check_areanpc(1,m,x,y,0)){
 	if(npc_check_areanpc(1,m,x,y,0)){
-		sd->count_rewarp++;	
+		sd->count_rewarp++;
 	}
 	}
 	else 
 	else 
 		sd->count_rewarp = 0;
 		sd->count_rewarp = 0;
@@ -11053,9 +11053,9 @@ static void pc_clear_log_damage_sub(uint32 char_id, struct mob_data *md)
 	uint8 i;
 	uint8 i;
 	ARR_FIND(0,DAMAGELOG_SIZE,i,md->dmglog[i].id == char_id);
 	ARR_FIND(0,DAMAGELOG_SIZE,i,md->dmglog[i].id == char_id);
 	if (i < DAMAGELOG_SIZE) {
 	if (i < DAMAGELOG_SIZE) {
-		md->dmglog[i].id=0;
-		md->dmglog[i].dmg=0;
-		md->dmglog[i].flag=0;
+		md->dmglog[i].id = 0;
+		md->dmglog[i].dmg = 0;
+		md->dmglog[i].flag = 0;
 	}
 	}
 }
 }
 
 
@@ -11068,15 +11068,19 @@ void pc_damage_log_add(struct map_session_data *sd, int id)
 {
 {
 	uint8 i = 0;
 	uint8 i = 0;
 
 
-	if (!sd)
+	if (!sd || !id)
 		return;
 		return;
 
 
 	//Only store new data, don't need to renew the old one with same id
 	//Only store new data, don't need to renew the old one with same id
+	ARR_FIND(0, DAMAGELOG_SIZE_PC, i, sd->dmglog[i] == id);
+	if (i < DAMAGELOG_SIZE_PC)
+		return;
+
 	for (i = 0; i < DAMAGELOG_SIZE_PC; i++) {
 	for (i = 0; i < DAMAGELOG_SIZE_PC; i++) {
-		if (sd->dmglog[i] == id)
+		if (sd->dmglog[i] == 0) {
+			sd->dmglog[i] = id;
 			return;
 			return;
-		sd->dmglog[i] = id;
-		return;
+		}
 	}
 	}
 }
 }
 
 

+ 11 - 10
src/map/script.c

@@ -18655,18 +18655,19 @@ BUILDIN_FUNC(instance_destroy)
  *------------------------------------------*/
  *------------------------------------------*/
 BUILDIN_FUNC(instance_enter)
 BUILDIN_FUNC(instance_enter)
 {
 {
-	struct map_session_data *sd;
+	struct map_session_data *sd = NULL;
+	int x = script_hasdata(st,3) ? script_getnum(st, 3) : -1;
+	int y = script_hasdata(st,4) ? script_getnum(st, 4) : -1;
 
 
-	if((sd = script_rid2sd(st)) != NULL){
-		if (script_hasdata(st,3) && script_hasdata(st,4))
-			script_pushint(st,instance_enter_position(sd,script_getstr(st, 2),script_getnum(st, 3),script_getnum(st, 4)));
-		else
-			script_pushint(st,instance_enter(sd,script_getstr(st, 2)));
-	}
-	else
+	if (!script_charid2sd(5,sd))
 		return SCRIPT_CMD_FAILURE;
 		return SCRIPT_CMD_FAILURE;
-	return SCRIPT_CMD_SUCCESS;
 
 
+	if (x != -1 && y != -1)
+		script_pushint(st,instance_enter_position(sd,script_getstr(st, 2),x,y));
+	else
+		script_pushint(st,instance_enter(sd,script_getstr(st, 2)));
+
+	return SCRIPT_CMD_SUCCESS;
 }
 }
 
 
 /*==========================================
 /*==========================================
@@ -21149,7 +21150,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(instance_create,"s"),
 	BUILDIN_DEF(instance_create,"s"),
 	BUILDIN_DEF(instance_destroy,"?"),
 	BUILDIN_DEF(instance_destroy,"?"),
 	BUILDIN_DEF(instance_id,""),
 	BUILDIN_DEF(instance_id,""),
-	BUILDIN_DEF(instance_enter,"s??"),
+	BUILDIN_DEF(instance_enter,"s???"),
 	BUILDIN_DEF(instance_npcname,"s?"),
 	BUILDIN_DEF(instance_npcname,"s?"),
 	BUILDIN_DEF(instance_mapname,"s?"),
 	BUILDIN_DEF(instance_mapname,"s?"),
 	BUILDIN_DEF(instance_warpall,"sii?"),
 	BUILDIN_DEF(instance_warpall,"sii?"),