Sfoglia il codice sorgente

- Implemented script commands for mercenary items (mercenary_heal and mercenary_sc_start).
- Fixed a bug crashing server with mercenary.

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

zephyrus 16 anni fa
parent
commit
f0439c9f56
5 ha cambiato i file con 45 aggiunte e 2 eliminazioni
  1. 8 0
      src/map/mercenary.c
  2. 1 0
      src/map/mercenary.h
  3. 2 2
      src/map/pc.c
  4. 33 0
      src/map/script.c
  5. 1 0
      src/map/status.c

+ 8 - 0
src/map/mercenary.c

@@ -218,6 +218,14 @@ void mercenary_damage(struct mercenary_data *md, struct block_list *src, int hp,
 	clif_mercenary_updatestatus(md->master, SP_HP);
 }
 
+void mercenary_heal(struct mercenary_data *md, int hp, int sp)
+{
+	if( hp )
+		clif_mercenary_updatestatus(md->master, SP_HP);
+	if( sp )
+		clif_mercenary_updatestatus(md->master, SP_SP);
+}
+
 int mercenary_dead(struct mercenary_data *md, struct block_list *src)
 {
 	merc_delete(md, 1);

+ 1 - 0
src/map/mercenary.h

@@ -42,6 +42,7 @@ int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime);
 int merc_data_received(struct s_mercenary *merc, bool flag);
 int mercenary_save(struct mercenary_data *md);
 void mercenary_damage(struct mercenary_data *md, struct block_list *src, int hp, int sp);
+void mercenary_heal(struct mercenary_data *md, int hp, int sp);
 int mercenary_dead(struct mercenary_data *md, struct block_list *src);
 int do_init_mercenary(void);
 int merc_delete(struct mercenary_data *md, int reply);

+ 2 - 2
src/map/pc.c

@@ -3602,8 +3602,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
 	if( sd->md )
 	{
 		sd->md->bl.m = m;
-		sd->md->bl.x = sd->hd->ud.to_x = x;
-		sd->md->bl.y = sd->hd->ud.to_y = y;
+		sd->md->bl.x = sd->md->ud.to_x = x;
+		sd->md->bl.y = sd->md->ud.to_y = y;
 		sd->md->ud.dir = sd->ud.dir;
 	}
 

+ 33 - 0
src/map/script.c

@@ -12815,6 +12815,37 @@ BUILDIN_FUNC(createmercenary)
 	return 0;
 }
 
+BUILDIN_FUNC(mercenary_heal)
+{
+	struct map_session_data *sd = script_rid2sd(st);
+	int hp, sp;
+
+	if( sd == NULL || sd->md == NULL )
+		return 0;
+	hp = script_getnum(st,2);
+	sp = script_getnum(st,3);
+
+	status_heal(&sd->md->bl, hp, sp, 0);	
+	return 0;
+}
+
+BUILDIN_FUNC(mercenary_sc_start)
+{
+	struct map_session_data *sd = script_rid2sd(st);
+	enum sc_type type;
+	int tick, val1;
+
+	if( sd == NULL || sd->md == NULL )
+		return 0;
+
+	type = (sc_type)script_getnum(st,2);
+	tick = script_getnum(st,3);
+	val1 = script_getnum(st,4);
+
+	status_change_start(&sd->md->bl, type, 10000, val1, 0, 0, 0, tick, 2);
+	return 0;
+}
+
 /******************
 Questlog script commands
 *******************/
@@ -13246,5 +13277,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(setwall,"siiiiis"),
 	BUILDIN_DEF(delwall,"s"),
 	BUILDIN_DEF(createmercenary,"ii"),
+	BUILDIN_DEF(mercenary_heal,"ii"),
+	BUILDIN_DEF(mercenary_sc_start,"iii"),
 	{NULL,NULL,NULL},
 };

+ 1 - 0
src/map/status.c

@@ -836,6 +836,7 @@ int status_heal(struct block_list *bl,int hp,int sp, int flag)
 	case BL_PC:  pc_heal((TBL_PC*)bl,hp,sp,flag&2?1:0); break;
 	case BL_MOB: mob_heal((TBL_MOB*)bl,hp); break;
 	case BL_HOM: merc_hom_heal((TBL_HOM*)bl,hp,sp); break;
+	case BL_MER: mercenary_heal((TBL_MER*)bl,hp,sp); break;
 	}
 
 	return hp+sp;