Procházet zdrojové kódy

* [Added]:
- buildin_checkcell, buildin_mobwarp, buildin_pcattack.
* [Improved]:
- buildin_skilluseid and buildin_skillusepos to accept a few more arguments.
- mob_script_callback to return sucess value.

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

Lance před 19 roky
rodič
revize
58b728cc4a
8 změnil soubory, kde provedl 94 přidání a 25 odebrání
  1. 5 0
      Changelog-Trunk.txt
  2. 1 0
      npc/sample/monster_controller.cpp
  3. 1 1
      src/map/clif.c
  4. 1 0
      src/map/clif.h
  5. 4 4
      src/map/mob.c
  6. 1 1
      src/map/mob.h
  7. 1 0
      src/map/npc.c
  8. 80 19
      src/map/script.c

+ 5 - 0
Changelog-Trunk.txt

@@ -4,6 +4,11 @@ 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/17
+	* [Added]:
+	  - buildin_checkcell, buildin_mobwarp, buildin_pcattack.
+	  [Improved]:
+	  - buildin_skilluseid and buildin_skillusepos to accept a few more arguments.
+	  - mob_script_callback to return sucess value [Lance]
 	* Fixed the party HP packets to send max HP 10000 and scale HP accordingly
 	  when the player's HP doesn't fits in the packet's field. Fixes HP bars not
 	  correctly displaying the % of life when max HP is above 32k. [Skotlex]

+ 1 - 0
npc/sample/monster_controller.cpp

@@ -87,6 +87,7 @@ prontera.gat,180,200,4	script	Monster Controller	123,{
 				break;
 			case AI_ACTION_TYPE_DEAD:
 				set .@action_type$, "Killed by";
+				remove_mob .ai_action[AI_ACTION_SRC];
 				break;
 			case AI_ACTION_TYPE_ASSIST:
 				set .@action_type$, "Assisting";

+ 1 - 1
src/map/clif.c

@@ -8624,7 +8624,7 @@ void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) {
 	WFIFOSET(fd,packet_len_table[0xc2]);
 }
 
-static void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)
+void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)
 {
 	unsigned char buf[64];
 	if (pc_isdead(sd)) {

+ 1 - 0
src/map/clif.h

@@ -143,6 +143,7 @@ void clif_adopt_process(struct map_session_data *sd);
 void clif_sitting(struct map_session_data *sd);
 void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,char *name,int type);
 int clif_soundeffectall(struct block_list *bl, char *name, int type, int coverage);
+void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick);
 
 // trade
 int clif_traderequest(struct map_session_data *sd,char *name);

+ 4 - 4
src/map/mob.c

@@ -771,10 +771,8 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
 	if ((*target) == bl || !status_check_skilluse(&md->bl, bl, 0, 0))
 		return 0;
 
-	if(md->nd){
-		mob_script_callback(md, bl, CALLBACK_DETECT);
+	if(md->nd && mob_script_callback(md, bl, CALLBACK_DETECT))
 		return 1; // We have script handling the work.
-	}
 
 	if(battle_check_target(&md->bl,bl,BCT_ENEMY)<=0)
 		return 0;
@@ -2992,7 +2990,7 @@ int mob_clone_delete(int class_)
 	return 0;
 }
 
-void mob_script_callback(struct mob_data *md, struct block_list *target, unsigned char action_type)
+int mob_script_callback(struct mob_data *md, struct block_list *target, unsigned char action_type)
 {
 	// I will not add any protection here since I assume everything is checked before coming here.
 	if(md->callback_flag&action_type){
@@ -3003,7 +3001,9 @@ void mob_script_callback(struct mob_data *md, struct block_list *target, unsigne
 		}
 		setd_sub(NULL, NULL, ".ai_action", 3, (void *)md->bl.id, &md->nd->u.scr.script->script_vars);
 		run_script(md->nd->u.scr.script, 0, 0, md->nd->bl.id);
+		return 1;
 	}
+	return 0;
 }
 
 //

+ 1 - 1
src/map/mob.h

@@ -35,7 +35,7 @@
 #define CALLBACK_WALKACK	0x02
 #define CALLBACK_WARPACK	0x01
 
-void mob_script_callback(struct mob_data *md, struct block_list *target, unsigned char action_type);
+int mob_script_callback(struct mob_data *md, struct block_list *target, unsigned char action_type);
 
 struct mob_skill {
 	short state;

+ 1 - 0
src/map/npc.c

@@ -1094,6 +1094,7 @@ int npc_click(struct map_session_data *sd,struct block_list *bl)
 				return 1;
 			if((nd = ((TBL_MOB *)bl)->nd) == NULL)
 				return 1;
+			setd_sub(NULL,sd,"@smc_target",0,(void *)bl->id, NULL);
 			break;
 		case BL_NPC:
 			if ((nd = npc_checknear(sd,bl)) == NULL)

+ 80 - 19
src/map/script.c

@@ -397,6 +397,7 @@ int buildin_getequipcardid(struct script_state *st); //[Lupus] returns card id f
 int buildin_sqrt(struct script_state *st);
 int buildin_pow(struct script_state *st);
 int buildin_distance(struct script_state *st);
+int buildin_checkcell(struct script_state *st);
 // <--- [zBuffer] List of mathematics commands
 // [zBuffer] List of dynamic var commands --->
 int buildin_getd(struct script_state *st);
@@ -419,11 +420,13 @@ int buildin_pcemote(struct script_state *st);
 int buildin_pcfollow(struct script_state *st);
 int buildin_pcstopfollow(struct script_state *st);
 int buildin_pcblockmove(struct script_state *st);
+int buildin_pcattack(struct script_state *st);
 // <--- [zBuffer] List of player cont commands
 // [zBuffer] List of mob control commands --->
 int buildin_spawnmob(struct script_state *st);
 int buildin_removemob(struct script_state *st);
 int buildin_mobwalk(struct script_state *st);
+int buildin_mobwarp(struct script_state *st);
 int buildin_getmobdata(struct script_state *st);
 int buildin_setmobdata(struct script_state *st);
 int buildin_mobattack(struct script_state *st);
@@ -696,9 +699,9 @@ struct {
 	{buildin_checkoption2,"checkoption2","i"},
 	{buildin_guildgetexp,"guildgetexp","i"},
 	{buildin_guildchangegm,"guildchangegm","is"},
-	{buildin_skilluseid,"skilluseid","ii"}, // originally by Qamera [Celest]
-	{buildin_skilluseid,"doskill","ii"}, // since a lot of scripts would already use 'doskill'...
-	{buildin_skillusepos,"skillusepos","iiii"}, // [Celest]
+	{buildin_skilluseid,"skilluseid","ii*"}, // originally by Qamera [Celest]
+	{buildin_skilluseid,"doskill","ii*"}, // since a lot of scripts would already use 'doskill'...
+	{buildin_skillusepos,"skillusepos","iiii*"}, // [Celest]
 	{buildin_logmes,"logmes","s"}, //this command actls as MES but rints info into LOG file either SQL/TXT [Lupus]
 	{buildin_summon,"summon","si*"}, // summons a slave monster [Celest]
 	{buildin_isnight,"isnight",""}, // check whether it is night time [Celest]
@@ -736,6 +739,7 @@ struct {
 	{buildin_sqrt,"sqrt","i"},
 	{buildin_pow,"pow","ii"},
 	{buildin_distance,"distance","iiii"},
+	{buildin_checkcell,"checkcell","siii"},
 	// <--- [zBuffer] List of mathematics commands
 	// [zBuffer] List of dynamic var commands --->
 	{buildin_getd,"getd","*"},
@@ -762,11 +766,13 @@ struct {
 	{buildin_pcfollow,"pcfollow","ii"},
 	{buildin_pcstopfollow,"pcstopfollow","i"},
 	{buildin_pcblockmove,"pcblockmove","ii"},
+	{buildin_pcattack,"pcattack","iii"},
 	// <--- [zBuffer] List of player cont commands
 	// [zBuffer] List of mob control commands --->
 	{buildin_spawnmob,"spawnmob","*"},
 	{buildin_removemob,"removemob","i"},
 	{buildin_mobwalk,"mobwalk","i*"},
+	{buildin_mobwarp,"mobwarp","isii"},
 	{buildin_mobrandomwalk,"mobrandomwalk","ii"},
 	{buildin_getmobdata,"getmobdata","i*"},
 	{buildin_setmobdata,"setmobdata","iii"},
@@ -9355,16 +9361,20 @@ int buildin_getmapxy(struct script_state *st){
  */
 int buildin_skilluseid (struct script_state *st)
 {
-   int skid,sklv;
-   struct map_session_data *sd;
+	int skid,sklv;
+	struct map_session_data *sd;
+
+	skid=conv_num(st,& (st->stack->stack_data[st->start+2]));
+	sklv=conv_num(st,& (st->stack->stack_data[st->start+3]));
+	if(st->end > st->start+4)
+		sd=(TBL_PC *)map_id2bl(conv_num(st,& (st->stack->stack_data[st->start+4])));
+	else
+		sd=script_rid2sd(st);
 
-   skid=conv_num(st,& (st->stack->stack_data[st->start+2]));
-   sklv=conv_num(st,& (st->stack->stack_data[st->start+3]));
-   sd=script_rid2sd(st);
 	if (sd)
-	   unit_skilluse_id(&sd->bl,sd->bl.id,skid,sklv);
+		unit_skilluse_id(&sd->bl,(st->end>st->start+5)?conv_num(st,& (st->stack->stack_data[st->start+5])):sd->bl.id,skid,sklv);
 
-   return 0;
+	return 0;
 }
 
 /*=====================================================
@@ -9373,19 +9383,23 @@ int buildin_skilluseid (struct script_state *st)
  */
 int buildin_skillusepos(struct script_state *st)
 {
-   int skid,sklv,x,y;
-   struct map_session_data *sd;
+	int skid,sklv,x,y;
+	struct map_session_data *sd;
+
+	skid=conv_num(st,& (st->stack->stack_data[st->start+2]));
+	sklv=conv_num(st,& (st->stack->stack_data[st->start+3]));
+	x=conv_num(st,& (st->stack->stack_data[st->start+4]));
+	y=conv_num(st,& (st->stack->stack_data[st->start+5]));
 
-   skid=conv_num(st,& (st->stack->stack_data[st->start+2]));
-   sklv=conv_num(st,& (st->stack->stack_data[st->start+3]));
-   x=conv_num(st,& (st->stack->stack_data[st->start+4]));
-   y=conv_num(st,& (st->stack->stack_data[st->start+5]));
+	if(st->end > st->start+5)
+		sd=(TBL_PC *)map_id2bl(conv_num(st,& (st->stack->stack_data[st->start+5])));
+	else
+		sd=script_rid2sd(st);
 
-   sd=script_rid2sd(st);
 	if (sd)
-	   unit_skilluse_pos(&sd->bl,x,y,skid,sklv);
+		unit_skilluse_pos(&sd->bl,x,y,skid,sklv);
 
-   return 0;
+	return 0;
 }
 
 /*==========================================
@@ -9922,6 +9936,18 @@ int buildin_distance(struct script_state *st){
 	return 0;
 }
 
+int buildin_checkcell(struct script_state *st){
+	int m;
+	char *map = conv_str(st, &(st->stack->stack_data[st->start+2]));
+	m = mapindex_name2id(map);
+	if(m){
+		push_val(st->stack, C_INT, map_getcell(m, conv_num(st, &(st->stack->stack_data[st->start+3])), conv_num(st, &(st->stack->stack_data[st->start+4])),conv_num(st, &(st->stack->stack_data[st->start+5]))));
+	} else {
+		push_val(st->stack, C_INT, 0);
+	}
+	return 0;
+}
+
 // <--- [zBuffer] List of mathematics commands
 // [zBuffer] List of dynamic var commands --->
 void setd_sub(struct script_state *st, struct map_session_data *sd, char *varname, int elem, void *value, struct linkdb_node **ref)
@@ -10474,6 +10500,22 @@ int buildin_pctalk(struct script_state *st){
 	return 0;
 }
 
+int buildin_pcattack(struct script_state *st) {
+	struct map_session_data *sd = NULL;
+
+	int id = conv_num(st, & (st->stack->stack_data[st->start + 2]));
+
+	if(id)
+		sd = map_id2sd(id);
+	else
+		sd = script_rid2sd(st);
+
+	if(sd)
+		clif_parse_ActionRequest_sub(sd, conv_num(st, & (st->stack->stack_data[st->start + 4]))>0?0x07:0x00, conv_num(st, & (st->stack->stack_data[st->start + 3])), gettick());
+
+	return 0;
+}
+
 int buildin_pcemote(struct script_state *st) {
 	int id, emo;
 	struct map_session_data *sd = NULL;
@@ -10589,6 +10631,25 @@ int buildin_mobwalk(struct script_state *st){
 	return 0;
 }
 
+int buildin_mobwarp(struct script_state *st){
+	int id,x,y,m = 0;
+	char *map;
+	struct block_list *bl = NULL;
+
+	id = conv_num(st, & (st->stack->stack_data[st->start+2]));
+	map = conv_str(st, & (st->stack->stack_data[st->start+3]));
+	x = conv_num(st, & (st->stack->stack_data[st->start+4]));
+	y = conv_num(st, & (st->stack->stack_data[st->start+5]));
+
+	bl = map_id2bl(id);
+	m = mapindex_name2id(map);
+	if(m && bl){
+		unit_warp(bl, m, (short)x, (short)y, 0);
+	}
+
+	return 0;
+}
+
 int buildin_getmobdata(struct script_state *st) {
 	int num, id;
 	char *name;