From 98bf635c00bbf45c0fe8e29a2d6d296e02a4af7c Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 2 Mar 2009 07:08:49 -0700 Subject: Add another function for checking player location You can now check to see if they are in a specified rectangle. --- src/map/script.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index 884f1bc..19557c7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -289,6 +289,7 @@ int buildin_getlook(struct script_state *st); //Lorky [Lupus] int buildin_getsavepoint(struct script_state *st); //Lorky [Lupus] int buildin_getpartnerid(struct script_state *st); // [Fate] int buildin_areatimer(struct script_state *st); // [Jaxad0127] +int buildin_isin(struct script_state *st); // [Jaxad0127] void push_val(struct script_stack *stack,int type,int val); int run_func(struct script_state *st); @@ -498,7 +499,8 @@ struct { {buildin_mobcount,"mobcount","ss"}, {buildin_getlook,"getlook","i"}, {buildin_getsavepoint,"getsavepoint","i"}, - {buildin_areatimer,"areatimer","siiiiis"}, // End Additions + {buildin_areatimer,"areatimer","siiiiis"}, + {buildin_isin,"isin","siiii"}, // End Additions {NULL,NULL,NULL}, }; int buildin_message(struct script_state *st); // [MouseJstr] @@ -6075,7 +6077,32 @@ int buildin_areatimer(struct script_state *st) return 0; } +/*========================================== + * Check whether the PC is in the specified rectangle + *------------------------------------------ + */ +int buildin_isin(struct script_state *st) +{ + int x1,y1,x2,y2; + char *str; + struct map_session_data *sd=script_rid2sd(st); + + str=conv_str(st,& (st->stack->stack_data[st->start+2])); + x1=conv_num(st,& (st->stack->stack_data[st->start+3])); + y1=conv_num(st,& (st->stack->stack_data[st->start+4])); + x2=conv_num(st,& (st->stack->stack_data[st->start+5])); + y2=conv_num(st,& (st->stack->stack_data[st->start+6])); + if (!sd) + return 1; + + push_val(st->stack, C_INT, + (sd->bl.x >= x1 && sd->bl.x <= x2) + && (sd->bl.y >= y1 && sd->bl.y <= y2) + && (!strcmp(str, map[sd->bl.m].name))); + + return 0; +} // // ˇĄ¨s•”main -- cgit v1.2.3-60-g2f50