summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c86
-rw-r--r--src/map/mob.c25
-rw-r--r--src/map/script.c102
3 files changed, 138 insertions, 75 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 556a48f8d..07ea1598d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -9435,53 +9435,53 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <ni
log_chat("W", 0, sd->status.char_id, sd->status.account_id, (char*)mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, (char*)RFIFOP(fd, 4), (char*)RFIFOP(fd, 28));
-//-------------------------------------------------------//
-// Lordalfa - Paperboy - To whisper NPC commands //
-//-------------------------------------------------------//
-if ((strncasecmp((const char*)RFIFOP(fd,4),"NPC:",4) == 0) && (strlen((const char*)RFIFOP(fd,4)) >4)) {
- whisper_tmp = (char*) RFIFOP(fd,4) + 4;
- if ((npc = npc_name2id(whisper_tmp)))
- {
- whisper_tmp=(char *)aCallocA(strlen((char *)(RFIFOP(fd,28)))+1,sizeof(char));
- whisper_tmp[0]=0;
-
- sprintf(whisper_tmp, "%s", (const char*)RFIFOP(fd,28));
- for( j=0;whisper_tmp[j]!='\0';j++)
+ //-------------------------------------------------------//
+ // Lordalfa - Paperboy - To whisper NPC commands //
+ //-------------------------------------------------------//
+ if ((strncasecmp((const char*)RFIFOP(fd,4),"NPC:",4) == 0) && (strlen((const char*)RFIFOP(fd,4)) >4)) {
+ whisper_tmp = (char*) RFIFOP(fd,4) + 4;
+ if ((npc = npc_name2id(whisper_tmp)))
{
- if(whisper_tmp[j]!='#')
+ whisper_tmp=(char *)aCallocA(strlen((char *)(RFIFOP(fd,28)))+1,sizeof(char));
+ whisper_tmp[0]=0;
+
+ sprintf(whisper_tmp, "%s", (const char*)RFIFOP(fd,28));
+ for( j=0;whisper_tmp[j]!='\0';j++)
{
- split_data[i][j-k]=whisper_tmp[j];
- }
- else
+ if(whisper_tmp[j]!='#')
+ {
+ split_data[i][j-k]=whisper_tmp[j];
+ }
+ else
+ {
+ split_data[i][j-k]='\0';
+ k=j+1;
+ i++;
+ }
+ } // Splits the message using '#' as separators
+ split_data[i][j-k]='\0';
+
+ aFree(whisper_tmp);
+ whisper_tmp=(char *)aCallocA(15,sizeof(char));
+ whisper_tmp[0]=0;
+
+ for (j=0;j<=10;j++)
{
- split_data[i][j-k]='\0';
- k=j+1;
- i++;
- }
- } // Splits the message using '#' as separators
- split_data[i][j-k]='\0';
-
- aFree(whisper_tmp);
- whisper_tmp=(char *)aCallocA(15,sizeof(char));
- whisper_tmp[0]=0;
-
- for (j=0;j<=10;j++)
- {
- sprintf(whisper_tmp, "@whispervar%d$", j);
- set_var(sd,whisper_tmp,(char *) split_data[j]);
- }//You don't need to zero them, just reset them [Kevin]
-
- aFree(whisper_tmp);
- whisper_tmp=(char *)aCallocA(strlen(npc->name)+18,sizeof(char));
- whisper_tmp[0]=0;
-
- sprintf(whisper_tmp, "%s::OnWhisperGlobal", npc->name);
- npc_event(sd,whisper_tmp,0); // Calls the NPC label
+ sprintf(whisper_tmp, "@whispervar%d$", j);
+ set_var(sd,whisper_tmp,(char *) split_data[j]);
+ }//You don't need to zero them, just reset them [Kevin]
+
+ aFree(whisper_tmp);
+ whisper_tmp=(char *)aCallocA(strlen(npc->name)+18,sizeof(char));
+ whisper_tmp[0]=0;
+
+ sprintf(whisper_tmp, "%s::OnWhisperGlobal", npc->name);
+ npc_event(sd,whisper_tmp,0); // Calls the NPC label
- aFree(whisper_tmp); //I rewrote it a little to use memory allocation, a bit more stable =P [Kevin]
- return;
- } //should have just removed the one below that was a my bad =P
-}
+ aFree(whisper_tmp); //I rewrote it a little to use memory allocation, a bit more stable =P [Kevin]
+ return;
+ } //should have just removed the one below that was a my bad =P
+ }
// Main chat [LuzZza]
if(strcmpi((const char*)RFIFOP(fd,4), main_chat_nick) == 0) {
diff --git a/src/map/mob.c b/src/map/mob.c
index 24806b374..23d29b7a1 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2296,7 +2296,6 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
set_var(NULL, buffer, (void *)(int)src->type);
sprintf(buffer, "%s::OnDamage", md->nd->exname);
npc_event_do(buffer);
- return 0;
}
if(src->type == BL_PC) {
sd = (struct map_session_data *)src;
@@ -2847,21 +2846,21 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
npc_event(mvp_sd,md->npc_event,0);
} else if (mvp_sd) {
-//lordalfa
- pc_setglobalreg(mvp_sd,"killedrid",(md->class_));
- if(sd->state.event_kill_mob){
- if (script_config.event_script_type == 0) {
- struct npc_data *npc;
- if ((npc = npc_name2id(script_config.kill_mob_event_name))) {
- run_script(npc->u.scr.script,0,mvp_sd->bl.id,npc->bl.id); // PCKillNPC [Lance]
- ShowStatus("Event '"CL_WHITE"%s"CL_RESET"' executed.\n",script_config.kill_mob_event_name);
+ //lordalfa
+ pc_setglobalreg(mvp_sd,"killedrid",(md->class_));
+ if(mvp_sd->state.event_kill_mob){
+ if (script_config.event_script_type == 0) {
+ struct npc_data *npc;
+ if ((npc = npc_name2id(script_config.kill_mob_event_name))) {
+ run_script(npc->u.scr.script,0,mvp_sd->bl.id,npc->bl.id); // PCKillNPC [Lance]
+ ShowStatus("Event '"CL_WHITE"%s"CL_RESET"' executed.\n",script_config.kill_mob_event_name);
+ }
+ } else {
+ ShowStatus("%d '"CL_WHITE"%s"CL_RESET"' events executed.\n",
+ npc_event_doall_id(script_config.kill_mob_event_name, mvp_sd->bl.id), script_config.kill_mob_event_name);
}
- } else {
- ShowStatus("%d '"CL_WHITE"%s"CL_RESET"' events executed.\n",
- npc_event_doall_id(script_config.kill_mob_event_name, mvp_sd->bl.id), script_config.kill_mob_event_name);
}
}
-}
//[lordalfa]
(battle_config.mob_clear_delay) ? clif_clearchar_delay(tick+battle_config.mob_clear_delay,&md->bl,1) : clif_clearchar_area(&md->bl,1);
// clif_clearchar_area(&md->bl,1); //eh? Why send the same packet twice? [Skotlex]
diff --git a/src/map/script.c b/src/map/script.c
index b7322164c..2e218a29c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10138,31 +10138,95 @@ int buildin_getmobdata(struct script_state *st) {
}
int buildin_setmobdata(struct script_state *st){
- int num, id, i = 0;
+ int num, id, value;
char *name;
struct script_data dat;
struct mob_data *md = NULL;
id = conv_num(st, & (st->stack->stack_data[st->start+2]));
+ value = conv_num(st, & (st->stack->stack_data[st->start+3]));
if(!(md = (struct mob_data *)map_id2bl(id)) || st->stack->stack_data[st->start+3].type!=C_NAME ){
- ShowWarning("buildin_setmobdata: Error in argiment!\n");
+ ShowWarning("buildin_setmobdata: Error in argument!\n");
} else {
-#define INCREMENT dat.type=C_NAME; dat.u.num=add_str((unsigned char *) name)+(i<<24); get_val(st,&dat); i++
-#define VALUE(x) x = (dat.u.num == -1)? x : dat.u.num
- num=st->stack->stack_data[st->start+2].u.num;
- name=(char *)(str_buf+str_data[num&0x00ffffff].str);
- INCREMENT; VALUE(md->class_); INCREMENT; VALUE(md->level);
- INCREMENT; VALUE(md->hp); INCREMENT; VALUE(md->max_hp);
- INCREMENT; VALUE(md->hp); INCREMENT; VALUE(md->master_id);
- INCREMENT; VALUE(md->bl.m); INCREMENT; VALUE(md->bl.x);
- INCREMENT; VALUE(md->bl.y); INCREMENT; VALUE(md->speed);
- INCREMENT; VALUE(md->mode); INCREMENT; VALUE(md->state.state);
- INCREMENT; VALUE(md->special_state.ai); INCREMENT; VALUE(md->db->option);
- INCREMENT; VALUE(md->db->sex); INCREMENT; VALUE(md->db->view_class);
- INCREMENT; VALUE(md->db->hair); INCREMENT; VALUE(md->db->hair_color);
- INCREMENT; VALUE(md->db->head_buttom); INCREMENT; VALUE(md->db->head_mid);
- INCREMENT; VALUE(md->db->head_top); INCREMENT; VALUE(md->db->clothes_color);
- INCREMENT; VALUE(md->db->equip); INCREMENT; VALUE(md->db->weapon);
- INCREMENT; VALUE(md->dir);
+ switch(id){
+ case 0:
+ md->class_ = (short)value;
+ break;
+ case 1:
+ md->level = (unsigned short)value;
+ break;
+ case 2:
+ md->hp = value;
+ break;
+ case 3:
+ md->max_hp = value;
+ break;
+ case 4:
+ md->master_id = value;
+ break;
+ case 5:
+ md->bl.m = (short)value;
+ break;
+ case 6:
+ md->bl.x = (short)value;
+ break;
+ case 7:
+ md->bl.y = (short)value;
+ break;
+ case 8:
+ md->speed = (short)value;
+ break;
+ case 9:
+ md->mode = (short)value;
+ break;
+ case 10:
+ md->state.state = (unsigned int)value;
+ break;
+ case 11:
+ md->special_state.ai = (unsigned int)value;
+ break;
+ case 12:
+ md->db->option = (short)value;
+ break;
+ case 13:
+ md->db->sex = value;
+ break;
+ case 14:
+ md->db->view_class = value;
+ break;
+ case 15:
+ md->db->hair = (short)value;
+ break;
+ case 16:
+ md->db->hair_color = (short)value;
+ break;
+ case 17:
+ md->db->head_buttom = (short)value;
+ break;
+ case 18:
+ md->db->head_mid = (short)value;
+ break;
+ case 19:
+ md->db->head_top = (short)value;
+ break;
+ case 20:
+ md->db->clothes_color = (short)value;
+ break;
+ case 21:
+ md->db->equip = value;
+ break;
+ case 22:
+ md->db->weapon = (short)value;
+ break;
+ case 23:
+ md->db->shield = (short)value;
+ break;
+ case 24:
+ md->dir = (short)value;
+ break;
+ default:
+ ShowError("buildin_setmobdata: argument id is not identified.");
+ break;
+ }
}
return 0;
}