summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-26 18:54:07 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-26 18:54:07 +0000
commit2e35eff8bfe55314e30aaa2b88bd0bf1e7bd7647 (patch)
tree53fbb31579d6e7c4f9572090379dd0ac36c53000 /src/map
parent894951cb5bb625050cc6da1ce409aed575f034f0 (diff)
downloadhercules-2e35eff8bfe55314e30aaa2b88bd0bf1e7bd7647.tar.gz
hercules-2e35eff8bfe55314e30aaa2b88bd0bf1e7bd7647.tar.bz2
hercules-2e35eff8bfe55314e30aaa2b88bd0bf1e7bd7647.tar.xz
hercules-2e35eff8bfe55314e30aaa2b88bd0bf1e7bd7647.zip
* Patches to allow everything to work right. + 1 more sample script.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6779 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/mob.c22
-rw-r--r--src/map/pc.c69
-rw-r--r--src/map/script.c51
-rw-r--r--src/map/unit.c4
4 files changed, 89 insertions, 57 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index efa632ef9..1b148f629 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -808,7 +808,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
setd_sub(NULL, NULL, ".ai_action", 2, (void *)bl->id, &md->nd->u.scr.script->script_vars);
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 0; // We have script handling the work.
+ return 1; // We have script handling the work.
}
if(battle_check_target(&md->bl,bl,BCT_ENEMY)<=0)
@@ -997,6 +997,15 @@ int mob_unlocktarget(struct mob_data *md,int tick)
{
nullpo_retr(0, md);
+ if(md->nd){
+ struct block_list *tbl = map_id2bl(md->target_id);
+ setd_sub(NULL, NULL, ".ai_action", 0, (void *)(int)6, &md->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 1, (void *)(int)(tbl?tbl->type:0), &md->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 2, (void *)(tbl?tbl->id:0), &md->nd->u.scr.script->script_vars);
+ 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);
+ }
+
md->target_id=0;
md->state.skillstate=MSS_IDLE;
md->next_walktime=tick+rand()%3000+3000;
@@ -2160,6 +2169,17 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
guild_agit_break(md);
}
+ if(src->type == BL_MOB){
+ struct mob_data *smd = (struct mob_data *)src;
+ if(smd->nd){
+ setd_sub(NULL, NULL, ".ai_action", 0, (void *)(int)5, &smd->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 1, (void *)(int)md->bl.type, &smd->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 2, (void *)md->bl.id, &smd->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 3, (void *)smd->bl.id, &smd->nd->u.scr.script->script_vars);
+ run_script(smd->nd->u.scr.script, 0, 0, smd->nd->bl.id);
+ }
+ }
+
if(md->nd){
setd_sub(NULL, NULL, ".ai_action", 0, (void *)(int)3, &md->nd->u.scr.script->script_vars);
setd_sub(NULL, NULL, ".ai_action", 1, (void *)(int)src->type, &md->nd->u.scr.script->script_vars);
diff --git a/src/map/pc.c b/src/map/pc.c
index 2cce8cfa6..771bd5c7e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4527,37 +4527,48 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage)
}
clif_clearchar_area(&sd->bl,1);
- if (src && src->type == BL_PC) {
- struct map_session_data *ssd = (struct map_session_data *)src;
- if (ssd) {
- if (sd->state.event_death)
- pc_setglobalreg(sd,"killerrid",(ssd->status.account_id));
- if (ssd->state.event_kill_pc) {
- pc_setglobalreg(ssd, "killedrid", sd->bl.id);
- npc_script_event(ssd, NPCE_KILLPC);
+ if (src) {
+ if(src->type == BL_MOB){
+ struct mob_data *smd = (struct mob_data *)src;
+ if(smd->nd){
+ setd_sub(NULL, NULL, ".ai_action", 0, (void *)(int)5, &smd->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 1, (void *)(int)sd->bl.type, &smd->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 2, (void *)sd->bl.id, &smd->nd->u.scr.script->script_vars);
+ setd_sub(NULL, NULL, ".ai_action", 3, (void *)smd->bl.id, &smd->nd->u.scr.script->script_vars);
+ run_script(smd->nd->u.scr.script, 0, 0, smd->nd->bl.id);
}
- if (battle_config.pk_mode && ssd->status.manner >= 0 && battle_config.manner_system) {
- ssd->status.manner -= 5;
- if(ssd->status.manner < 0)
- sc_start(src,SC_NOCHAT,100,0,0);
-
- // PK/Karma system code (not enabled yet) [celest]
- // originally from Kade Online, so i don't know if any of these is correct ^^;
- // note: karma is measured REVERSE, so more karma = more 'evil' / less honourable,
- // karma going down = more 'good' / more honourable.
- // The Karma System way...
- /*if (sd->status.karma > ssd->status.karma) { // If player killed was more evil
- sd->status.karma--;
- ssd->status.karma--;
+ } else if(src->type == BL_PC){
+ struct map_session_data *ssd = (struct map_session_data *)src;
+ if (ssd) {
+ if (sd->state.event_death)
+ pc_setglobalreg(sd,"killerrid",(ssd->status.account_id));
+ if (ssd->state.event_kill_pc) {
+ pc_setglobalreg(ssd, "killedrid", sd->bl.id);
+ npc_script_event(ssd, NPCE_KILLPC);
+ }
+ if (battle_config.pk_mode && ssd->status.manner >= 0 && battle_config.manner_system) {
+ ssd->status.manner -= 5;
+ if(ssd->status.manner < 0)
+ sc_start(src,SC_NOCHAT,100,0,0);
+
+ // PK/Karma system code (not enabled yet) [celest]
+ // originally from Kade Online, so i don't know if any of these is correct ^^;
+ // note: karma is measured REVERSE, so more karma = more 'evil' / less honourable,
+ // karma going down = more 'good' / more honourable.
+ // The Karma System way...
+ /*if (sd->status.karma > ssd->status.karma) { // If player killed was more evil
+ sd->status.karma--;
+ ssd->status.karma--;
+ }
+ else if (sd->status.karma < ssd->status.karma) // If player killed was more good
+ ssd->status.karma++;*/
+
+ // or the PK System way...
+ /* if (sd->status.karma > 0) // player killed is dishonourable?
+ ssd->status.karma--; // honour points earned
+ sd->status.karma++; // honour points lost */
+ // To-do: Receive exp on certain occasions
}
- else if (sd->status.karma < ssd->status.karma) // If player killed was more good
- ssd->status.karma++;*/
-
- // or the PK System way...
- /* if (sd->status.karma > 0) // player killed is dishonourable?
- ssd->status.karma--; // honour points earned
- sd->status.karma++; // honour points lost */
- // To-do: Receive exp on certain occasions
}
}
} else {
diff --git a/src/map/script.c b/src/map/script.c
index 75ed89db6..d6d5e7123 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10514,37 +10514,38 @@ int buildin_getmobdata(struct script_state *st) {
int num, id;
char *name;
struct mob_data *md = NULL;
+ struct map_session_data *sd = st->rid?map_id2sd(st->rid):NULL;
id = conv_num(st, & (st->stack->stack_data[st->start+2]));
if(!(md = (struct mob_data *)map_id2bl(id)) || st->stack->stack_data[st->start+3].type!=C_NAME ){
ShowWarning("buildin_getmobdata: Error in argument!\n");
} else {
num=st->stack->stack_data[st->start+3].u.num;
name=(char *)(str_buf+str_data[num&0x00ffffff].str);
- setd_sub(st,map_id2sd(st->rid),name,0,(void *)(int)md->class_,NULL);
- setd_sub(st,map_id2sd(st->rid),name,1,(void *)(int)md->level,NULL);
- setd_sub(st,map_id2sd(st->rid),name,2,(void *)(int)md->hp,NULL);
- setd_sub(st,map_id2sd(st->rid),name,3,(void *)(int)md->max_hp,NULL);
- setd_sub(st,map_id2sd(st->rid),name,4,(void *)(int)md->master_id,NULL);
- setd_sub(st,map_id2sd(st->rid),name,5,(void *)(int)md->bl.m,NULL);
- setd_sub(st,map_id2sd(st->rid),name,6,(void *)(int)md->bl.x,NULL);
- setd_sub(st,map_id2sd(st->rid),name,7,(void *)(int)md->bl.y,NULL);
- setd_sub(st,map_id2sd(st->rid),name,8,(void *)(int)md->speed,NULL);
- setd_sub(st,map_id2sd(st->rid),name,9,(void *)(int)md->mode,NULL);
- setd_sub(st,map_id2sd(st->rid),name,10,(void *)(int)md->special_state.ai,NULL);
- setd_sub(st,map_id2sd(st->rid),name,11,(void *)(int)md->db->option,NULL);
- setd_sub(st,map_id2sd(st->rid),name,12,(void *)(int)md->vd->sex,NULL);
- setd_sub(st,map_id2sd(st->rid),name,13,(void *)(int)md->vd->class_,NULL);
- setd_sub(st,map_id2sd(st->rid),name,14,(void *)(int)md->vd->hair_style,NULL);
- setd_sub(st,map_id2sd(st->rid),name,15,(void *)(int)md->vd->hair_color,NULL);
- setd_sub(st,map_id2sd(st->rid),name,16,(void *)(int)md->vd->head_bottom,NULL);
- setd_sub(st,map_id2sd(st->rid),name,17,(void *)(int)md->vd->head_mid,NULL);
- setd_sub(st,map_id2sd(st->rid),name,18,(void *)(int)md->vd->head_top,NULL);
- setd_sub(st,map_id2sd(st->rid),name,19,(void *)(int)md->vd->cloth_color,NULL);
- setd_sub(st,map_id2sd(st->rid),name,20,(void *)(int)md->vd->shield,NULL);
- setd_sub(st,map_id2sd(st->rid),name,21,(void *)(int)md->vd->weapon,NULL);
- setd_sub(st,map_id2sd(st->rid),name,22,(void *)(int)md->vd->shield,NULL);
- setd_sub(st,map_id2sd(st->rid),name,23,(void *)(int)md->ud.dir,NULL);
- setd_sub(st,map_id2sd(st->rid),name,24,(void *)(int)md->state.killer,NULL);
+ setd_sub(st,sd,name,0,(void *)(int)md->class_,NULL);
+ setd_sub(st,sd,name,1,(void *)(int)md->level,NULL);
+ setd_sub(st,sd,name,2,(void *)(int)md->hp,NULL);
+ setd_sub(st,sd,name,3,(void *)(int)md->max_hp,NULL);
+ setd_sub(st,sd,name,4,(void *)(int)md->master_id,NULL);
+ setd_sub(st,sd,name,5,(void *)(int)md->bl.m,NULL);
+ setd_sub(st,sd,name,6,(void *)(int)md->bl.x,NULL);
+ setd_sub(st,sd,name,7,(void *)(int)md->bl.y,NULL);
+ setd_sub(st,sd,name,8,(void *)(int)md->speed,NULL);
+ setd_sub(st,sd,name,9,(void *)(int)(md->mode?md->mode:md->db->mode),NULL);
+ setd_sub(st,sd,name,10,(void *)(int)md->special_state.ai,NULL);
+ setd_sub(st,sd,name,11,(void *)(int)md->db->option,NULL);
+ setd_sub(st,sd,name,12,(void *)(int)md->vd->sex,NULL);
+ setd_sub(st,sd,name,13,(void *)(int)md->vd->class_,NULL);
+ setd_sub(st,sd,name,14,(void *)(int)md->vd->hair_style,NULL);
+ setd_sub(st,sd,name,15,(void *)(int)md->vd->hair_color,NULL);
+ setd_sub(st,sd,name,16,(void *)(int)md->vd->head_bottom,NULL);
+ setd_sub(st,sd,name,17,(void *)(int)md->vd->head_mid,NULL);
+ setd_sub(st,sd,name,18,(void *)(int)md->vd->head_top,NULL);
+ setd_sub(st,sd,name,19,(void *)(int)md->vd->cloth_color,NULL);
+ setd_sub(st,sd,name,20,(void *)(int)md->vd->shield,NULL);
+ setd_sub(st,sd,name,21,(void *)(int)md->vd->weapon,NULL);
+ setd_sub(st,sd,name,22,(void *)(int)md->vd->shield,NULL);
+ setd_sub(st,sd,name,23,(void *)(int)md->ud.dir,NULL);
+ setd_sub(st,sd,name,24,(void *)(int)md->state.killer,NULL);
}
return 0;
}
diff --git a/src/map/unit.c b/src/map/unit.c
index 610590848..9fc3003a1 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1084,8 +1084,8 @@ int unit_attack(struct block_list *src,int target_id,int type)
return 0;
}
- if(battle_check_target(src,target,BCT_ENEMY)<=0 ||
- !status_check_skilluse(src, target, 0, 0)
+ if(!(src->type == BL_MOB && !((TBL_MOB *)src)->state.killer) && (battle_check_target(src,target,BCT_ENEMY)<=0 ||
+ !status_check_skilluse(src, target, 0, 0))
) {
unit_unattackable(src);
return 1;