summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-17 07:48:10 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-17 07:48:10 +0000
commitf1af15f7af3118a718a2a2ea02156e778b96a16f (patch)
treee470f7e9361cca9df5f0c4c4a682e8d63ba9d0da /src/map
parent50d4640a538e16e718e8192ca12bc5ade1a7387f (diff)
downloadhercules-f1af15f7af3118a718a2a2ea02156e778b96a16f.tar.gz
hercules-f1af15f7af3118a718a2a2ea02156e778b96a16f.tar.bz2
hercules-f1af15f7af3118a718a2a2ea02156e778b96a16f.tar.xz
hercules-f1af15f7af3118a718a2a2ea02156e778b96a16f.zip
* [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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7219 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c2
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/mob.c8
-rw-r--r--src/map/mob.h2
-rw-r--r--src/map/npc.c1
-rw-r--r--src/map/script.c99
6 files changed, 88 insertions, 25 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 7abe50aa3..9c6d0e97a 100644
--- a/src/map/clif.c
+++ b/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)) {
diff --git a/src/map/clif.h b/src/map/clif.h
index 951f25065..3143cafb8 100644
--- a/src/map/clif.h
+++ b/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);
diff --git a/src/map/mob.c b/src/map/mob.c
index 686cb71d3..c4cedad2d 100644
--- a/src/map/mob.c
+++ b/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;
}
//
diff --git a/src/map/mob.h b/src/map/mob.h
index 34b3988ad..04d4df8f2 100644
--- a/src/map/mob.h
+++ b/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;
diff --git a/src/map/npc.c b/src/map/npc.c
index 4af7bc36f..69cb214e8 100644
--- a/src/map/npc.c
+++ b/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)
diff --git a/src/map/script.c b/src/map/script.c
index 09fa6a1cf..d30236694 100644
--- a/src/map/script.c
+++ b/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;