summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-26 07:21:48 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-26 07:21:48 +0000
commit4eabbb012ad6e6a4b9b3343e090b96de2841c1cf (patch)
treec7239af4c1e62dd9e6019fe1dd615df840422ce2 /src
parent245f3dbc96cbbefc890ef2cd957f71185470e32f (diff)
downloadhercules-4eabbb012ad6e6a4b9b3343e090b96de2841c1cf.tar.gz
hercules-4eabbb012ad6e6a4b9b3343e090b96de2841c1cf.tar.bz2
hercules-4eabbb012ad6e6a4b9b3343e090b96de2841c1cf.tar.xz
hercules-4eabbb012ad6e6a4b9b3343e090b96de2841c1cf.zip
* Change scripting engine's NPC scope vars to dot (.) style.
* Improved and (should be fully) fixed the mob control engine. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6769 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c3
-rw-r--r--src/char_sql/char.c3
-rw-r--r--src/map/battle.c4
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/script.c64
-rw-r--r--src/map/unit.c1
6 files changed, 44 insertions, 32 deletions
diff --git a/src/char/char.c b/src/char/char.c
index aac8135a9..34c366a84 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2917,9 +2917,10 @@ int parse_frommap(int fd) {
return 0;
}
- if(pos) // If the player's already in the list, remove the entry and shift the following ones 1 step up
+ if(pos){ // If the player's already in the list, remove the entry and shift the following ones 1 step up
memmove(list + pos - 1, list + pos, (size - pos) * sizeof(struct fame_list));
list[size].fame = 0; // At worst, the guy'll end up last (shouldn't happen if fame only goes up)
+ }
for(i = 0; i < size; i++) // Find the position where the player has to be inserted
if(fame >= list[i].fame) { // When found someone with less or as much fame, insert just above
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index ed76012d1..614140d85 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -2774,9 +2774,10 @@ int parse_frommap(int fd) {
return 0;
}
- if(pos) // If the player's already in the list, remove the entry and shift the following ones 1 step up
+ if(pos){ // If the player's already in the list, remove the entry and shift the following ones 1 step up
memmove(list + pos - 1, list + pos, (size - pos) * sizeof(struct fame_list));
list[size].fame = 0; // At worst, the guy'll end up last (shouldn't happen if fame only goes up)
+ }
for(i = 0; i < size; i++) // Find the position where the player has to be inserted
if(fame >= list[i].fame) { // When found someone with less or as much fame, insert just above
diff --git a/src/map/battle.c b/src/map/battle.c
index 77e5bc7d7..a263d4874 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3426,6 +3426,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
case BL_MOB:
{
TBL_MOB*md = (TBL_MOB*)s_bl;
+ if(md->state.killer) // Is on a rampage too :D
+ state |= BCT_ENEMY;
if (!agit_flag && md->guardian_data && md->guardian_data->guild_id)
return 0; //Disable guardians/emperium owned by Guilds on non-woe times.
if (!md->special_state.ai) { //Normal mobs.
@@ -3434,7 +3436,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
else
state |= BCT_ENEMY; //However, all else are enemies.
} else {
- //if (t_bl->type == BL_MOB && !((TBL_MOB*)t_bl)->special_state.ai)
+ if (t_bl->type == BL_MOB && !((TBL_MOB*)t_bl)->special_state.ai)
state |= BCT_ENEMY; //Natural enemy for AI mobs are normal mobs.
}
if (md->master_id && (s_bl = map_id2bl(md->master_id)) == NULL)
diff --git a/src/map/map.h b/src/map/map.h
index 66315cadc..aa8714349 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -871,6 +871,7 @@ struct mob_data {
unsigned soul_change_flag : 1; // Celest
unsigned alchemist: 1;
unsigned no_random_walk: 1;
+ unsigned killer: 1;
int provoke_flag; // Celest
} state;
struct guardian_data* guardian_data;
diff --git a/src/map/script.c b/src/map/script.c
index d167f8230..88d4ef9e7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -125,7 +125,7 @@ char tmp_sql[65535];
#endif
static struct linkdb_node *sleep_db;
-#define not_server_variable(prefix) (prefix != '$' && prefix != '\'')
+#define not_server_variable(prefix) (prefix != '$' && prefix != '.')
/*==========================================
* ローカルプロトタイプ宣言 (必要な物のみ)
@@ -1045,7 +1045,7 @@ static unsigned char *skip_space(unsigned char *p)
static unsigned char *skip_word(unsigned char *p)
{
// prefix
- if(*p=='\'') p++;
+ if(*p=='.') p++;
if(*p=='$') p++; // MAP鯖内共有変数用
if(*p=='@') p++; // 一時的変数用(like weiss)
if(*p=='#') p++; // account変数用
@@ -2349,7 +2349,7 @@ int get_val(struct script_state*st,struct script_data* data)
if(sd)
data->u.str = pc_readaccountregstr(sd,name);
}
- }else if(prefix=='\'') {
+ }else if(prefix=='.') {
struct linkdb_node **n;
if( data->ref ) {
n = data->ref;
@@ -2391,7 +2391,7 @@ int get_val(struct script_state*st,struct script_data* data)
if(sd)
data->u.num = pc_readaccountreg(sd,name);
}
- }else if(prefix=='\''){
+ }else if(prefix=='.'){
struct linkdb_node **n;
if( data->ref ) {
n = data->ref;
@@ -2444,7 +2444,7 @@ static int set_reg(struct script_state*st,struct map_session_data *sd,int num,ch
pc_setaccountreg2str(sd,name,str);
else
pc_setaccountregstr(sd,name,str);
- }else if(prefix=='\'') {
+ }else if(prefix=='.') {
char *p;
struct linkdb_node **n;
if( ref ) {
@@ -2482,7 +2482,7 @@ static int set_reg(struct script_state*st,struct map_session_data *sd,int num,ch
pc_setaccountreg2(sd,name,val);
else
pc_setaccountreg(sd,name,val);
- }else if(prefix == '\'') {
+ }else if(prefix == '.') {
struct linkdb_node **n;
if( ref ) {
n = ref;
@@ -2801,9 +2801,9 @@ int buildin_callfunc(struct script_state *st)
if( s->type == C_NAME && !s->ref ) {
char *name = str_buf+str_data[s->u.num&0x00ffffff].str;
// '@ 変数の引き継ぎ
- if( name[0] == '\'' && name[1] == '@' ) {
+ if( name[0] == '.' && name[1] == '@' ) {
s->ref = oldval;
- } else if( name[0] == '\'' ) {
+ } else if( name[0] == '.' ) {
s->ref = &oldscr->script_vars;
}
}
@@ -2849,7 +2849,7 @@ int buildin_callsub(struct script_state *st)
if( s->type == C_NAME && !s->ref ) {
char *name = str_buf+str_data[s->u.num&0x00ffffff].str;
// '@ 変数の引き継ぎ
- if( name[0] == '\'' && name[1] == '@' ) {
+ if( name[0] == '.' && name[1] == '@' ) {
s->ref = oldval;
}
}
@@ -2894,10 +2894,10 @@ int buildin_return(struct script_state *st)
sd = &st->stack->stack_data[st->stack->sp-1];
if(sd->type == C_NAME) {
char *name = str_buf + str_data[sd->u.num&0x00ffffff].str;
- if( name[0] == '\'' && name[1] == '@') {
+ if( name[0] == '.' && name[1] == '@') {
// '@ 変数を参照渡しにすると危険なので値渡しにする
get_val(st,sd);
- } else if( name[0] == '\'' && !sd->ref) {
+ } else if( name[0] == '.' && !sd->ref) {
// ' 変数は参照渡しでも良いが、参照元が設定されていないと
// 元のスクリプトの値を差してしまうので補正する。
sd->ref = &st->script->script_vars;
@@ -3492,7 +3492,7 @@ int buildin_setarray(struct script_state *st)
char postfix=name[strlen(name)-1];
int i,j;
- if( prefix!='$' && prefix!='@' && prefix!='\''){
+ if( prefix!='$' && prefix!='@' && prefix!='.'){
ShowWarning("buildin_setarray: illegal scope !\n");
return 1;
}
@@ -3524,7 +3524,7 @@ int buildin_cleararray(struct script_state *st)
int i;
void *v;
- if( prefix!='$' && prefix!='@' && prefix!='\''){
+ if( prefix!='$' && prefix!='@' && prefix!='.'){
ShowWarning("buildin_cleararray: illegal scope !\n");
return 1;
}
@@ -3558,11 +3558,11 @@ int buildin_copyarray(struct script_state *st)
int sz=conv_num(st,& (st->stack->stack_data[st->start+4]));
int i;
- if( prefix!='$' && prefix!='@' && prefix!='\'' ){
+ if( prefix!='$' && prefix!='@' && prefix!='.' ){
printf("buildin_copyarray: illeagal scope !\n");
return 0;
}
- if( prefix2!='$' && prefix2!='@' && prefix2!='\'' ) {
+ if( prefix2!='$' && prefix2!='@' && prefix2!='.' ) {
printf("buildin_copyarray: illeagal scope !\n");
return 0;
}
@@ -3619,7 +3619,7 @@ int buildin_getarraysize(struct script_state *st)
char prefix=*name;
char postfix=name[strlen(name)-1];
- if( prefix!='$' && prefix!='@' && prefix!='\'' ){
+ if( prefix!='$' && prefix!='@' && prefix!='.' ){
ShowWarning("buildin_copyarray: illegal scope !\n");
return 1;
}
@@ -3645,7 +3645,7 @@ int buildin_deletearray(struct script_state *st)
if( (st->end > st->start+3) )
count=conv_num(st,& (st->stack->stack_data[st->start+3]));
- if( prefix!='$' && prefix!='@' && prefix!='\'' ){
+ if( prefix!='$' && prefix!='@' && prefix!='.' ){
ShowWarning("buildin_deletearray: illegal scope !\n");
return 1;
}
@@ -10626,23 +10626,31 @@ int buildin_setmobdata(struct script_state *st){
}
int buildin_mobattack(struct script_state *st) {
- int id;
- char *target;
+ int id = 0;
+ char *target = NULL;
struct mob_data *md = NULL;
struct map_session_data *sd = NULL;
struct block_list *bl = NULL;
id = conv_num(st, & (st->stack->stack_data[st->start+2]));
- target = conv_str(st, & (st->stack->stack_data[st->start+3]));
+ if(st->end > st->start + 3)
+ target = conv_str(st, & (st->stack->stack_data[st->start+3]));
- if((sd = map_nick2sd(target)) != NULL || (bl = map_id2bl(atoi(target))) != NULL) {
- if (sd) bl = &sd->bl;
- md = (struct mob_data *)map_id2bl(id);
+ if(target){
+ sd = map_nick2sd(target);
+ if(!sd)
+ bl = map_id2bl(atoi(target));
+ else
+ bl = &sd->bl;
+ }
+
+ if((md = (struct mob_data *)map_id2bl(id))){
if (md && md->bl.type == BL_MOB) {
- md->target_id = bl->id;
- md->special_state.ai = 1;
- //md->min_chase = distance_bl(&md->bl,map_id2bl(md->target_id)) + md->db->range2;
- unit_walktobl(&md->bl, bl, 65025, 2);
+ md->state.killer = 1;
+ if(bl){
+ md->target_id = bl->id;
+ unit_walktobl(&md->bl, bl, 65025, 2);
+ }
}
}
@@ -10832,7 +10840,7 @@ int buildin_getvariableofnpc(struct script_state *st)
char *var_name = str_buf+str_data[num&0x00ffffff].str;
char *npc_name = conv_str(st,& (st->stack->stack_data[st->start+3]));
struct npc_data *nd = npc_name2id(npc_name);
- if( var_name[0] != '\'' || var_name[1] == '@' ) {
+ if( var_name[0] != '.' || var_name[1] == '@' ) {
// ' 変数以外はダメ
printf("getvariableofnpc: invalid scope %s\n", var_name);
push_val(st->stack,C_INT,0);
diff --git a/src/map/unit.c b/src/map/unit.c
index f0ce5c9ca..610590848 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1087,7 +1087,6 @@ int unit_attack(struct block_list *src,int target_id,int type)
if(battle_check_target(src,target,BCT_ENEMY)<=0 ||
!status_check_skilluse(src, target, 0, 0)
) {
- ShowWarning("%d can't attack. :(",src->id);
unit_unattackable(src);
return 1;
}