Added a simplified version of Qamera's OnConnect: OnDisconnect: OnDeath: NPC events mod
git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@914 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
7b9e4133c8
commit
c0631c4114
@ -1,5 +1,19 @@
|
|||||||
Date Added
|
Date Added
|
||||||
01/05
|
01/05
|
||||||
|
* Added a simplified version of Qamera's OnConnect: OnDisconnect: OnDeath:
|
||||||
|
NPC events mod, (All credits go to him.) except adapted based on eA's current
|
||||||
|
PCLoginEvent. (by davidsiaw) [celest]
|
||||||
|
- Currently only 4 events have been added: PCDieEvent, PCKillEvent,
|
||||||
|
PCLogoutEvent and PCLoginEvent
|
||||||
|
- For notes and usage example check /npc/sample/PCLoginEvent.txt (by
|
||||||
|
davidsiaw)
|
||||||
|
- To enable them for a player in a script, do
|
||||||
|
"set <name of event>, <0 or 1>;"
|
||||||
|
(yes it's saved in a permanent character variable and auto read every time)
|
||||||
|
- Simply put, if any of them is set to 1 the appropiate event will activate
|
||||||
|
p.s - Scripters who are already using PcLoginEvent, you'll need to add a
|
||||||
|
"set PCLoginEvent, 1;" now, sorry for the trouble.
|
||||||
|
|
||||||
* Optimised PCLoginEvent activation a bit [celest]
|
* Optimised PCLoginEvent activation a bit [celest]
|
||||||
* Set 'droprate0item''s default to 'yes' so that items with 0 rate will never
|
* Set 'droprate0item''s default to 'yes' so that items with 0 rate will never
|
||||||
drop [celest]
|
drop [celest]
|
||||||
|
@ -969,6 +969,14 @@ void map_addnickdb(struct map_session_data *sd) {
|
|||||||
int map_quit(struct map_session_data *sd) {
|
int map_quit(struct map_session_data *sd) {
|
||||||
nullpo_retr(0, sd);
|
nullpo_retr(0, sd);
|
||||||
|
|
||||||
|
if (sd->state.event_disconnect) {
|
||||||
|
struct npc_data *npc;
|
||||||
|
if ((npc = npc_name2id("PCLogoutEvent"))) {
|
||||||
|
run_script(npc->u.scr.script,0,sd->bl.id,npc->bl.id); // PCLogoutNPC
|
||||||
|
ShowStatus("Event '"CL_WHITE"PCLogoutEvent"CL_RESET"' executed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(sd->chatID) // チャットから出る
|
if(sd->chatID) // チャットから出る
|
||||||
chat_leavechat(sd);
|
chat_leavechat(sd);
|
||||||
|
|
||||||
|
@ -143,6 +143,11 @@ struct map_session_data {
|
|||||||
int glorywounds_flag;
|
int glorywounds_flag;
|
||||||
int soulcold_flag;
|
int soulcold_flag;
|
||||||
int hawkeyes_flag;
|
int hawkeyes_flag;
|
||||||
|
// originally by Qamera, adapted by celest
|
||||||
|
unsigned event_death : 1;
|
||||||
|
unsigned event_kill : 1;
|
||||||
|
unsigned event_disconnect : 1;
|
||||||
|
unsigned event_onconnect : 1;
|
||||||
} state;
|
} state;
|
||||||
struct {
|
struct {
|
||||||
unsigned killer : 1;
|
unsigned killer : 1;
|
||||||
|
38
src/map/pc.c
38
src/map/pc.c
@ -872,6 +872,12 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars
|
|||||||
//スパノビ用死にカウンタ?のスクリプト??からの?み出しとsdへのセット
|
//スパノビ用死にカウンタ?のスクリプト??からの?み出しとsdへのセット
|
||||||
sd->die_counter = pc_readglobalreg(sd,"PC_DIE_COUNTER");
|
sd->die_counter = pc_readglobalreg(sd,"PC_DIE_COUNTER");
|
||||||
|
|
||||||
|
// Automated script events
|
||||||
|
sd->state.event_death = pc_readglobalreg(sd,"PCDieEvent");
|
||||||
|
sd->state.event_kill = pc_readglobalreg(sd,"PCKillEvent");
|
||||||
|
sd->state.event_disconnect = pc_readglobalreg(sd,"PCLogoffEvent");
|
||||||
|
sd->state.event_onconnect = pc_readglobalreg(sd,"PCLoginEvent");
|
||||||
|
|
||||||
if (night_flag == 1 && !map[sd->bl.m].flag.indoors) {
|
if (night_flag == 1 && !map[sd->bl.m].flag.indoors) {
|
||||||
char tmpstr[1024];
|
char tmpstr[1024];
|
||||||
strcpy(tmpstr, msg_txt(500)); // Actually, it's the night...
|
strcpy(tmpstr, msg_txt(500)); // Actually, it's the night...
|
||||||
@ -892,7 +898,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars
|
|||||||
sprintf(tmp_output,"Character '"CL_WHITE"%s"CL_RESET"' logged in. (Account ID: '"CL_WHITE"%d"CL_RESET"').\n", sd->status.name, sd->status.account_id);
|
sprintf(tmp_output,"Character '"CL_WHITE"%s"CL_RESET"' logged in. (Account ID: '"CL_WHITE"%d"CL_RESET"').\n", sd->status.name, sd->status.account_id);
|
||||||
ShowInfo(tmp_output);
|
ShowInfo(tmp_output);
|
||||||
|
|
||||||
{
|
if (sd->state.event_onconnect) {
|
||||||
struct npc_data *npc;
|
struct npc_data *npc;
|
||||||
//printf("pc: OnPCLogin event done. (%d events)\n", npc_event_doall("OnPCLogin") );
|
//printf("pc: OnPCLogin event done. (%d events)\n", npc_event_doall("OnPCLogin") );
|
||||||
if ((npc = npc_name2id("PCLoginEvent"))) {
|
if ((npc = npc_name2id("PCLoginEvent"))) {
|
||||||
@ -5602,6 +5608,27 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage)
|
|||||||
clif_updatestatus(sd,SP_HP);
|
clif_updatestatus(sd,SP_HP);
|
||||||
pc_calcstatus(sd,0);
|
pc_calcstatus(sd,0);
|
||||||
|
|
||||||
|
if (sd->state.event_death) {
|
||||||
|
struct npc_data *npc;
|
||||||
|
if ((npc = npc_name2id("PCDeathEvent"))) {
|
||||||
|
run_script(npc->u.scr.script,0,sd->bl.id,npc->bl.id); // PCDeathNPC
|
||||||
|
ShowStatus("Event '"CL_WHITE"PCDeathEvent"CL_RESET"' executed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (src && src->type == BL_PC) {
|
||||||
|
if (((struct map_session_data *)src)->state.event_kill) {
|
||||||
|
struct npc_data *npc;
|
||||||
|
if ((npc = npc_name2id("PCKillEvent"))) {
|
||||||
|
run_script(npc->u.scr.script,0,sd->bl.id,npc->bl.id); // PCKillNPC
|
||||||
|
ShowStatus("Event '"CL_WHITE"PCKillEvent"CL_RESET"' executed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sd->state.event_death)
|
||||||
|
pc_setglobalreg(sd,"killerrid",((struct map_session_data *)src)->status.account_id);
|
||||||
|
}
|
||||||
|
|
||||||
if(battle_config.bone_drop==2
|
if(battle_config.bone_drop==2
|
||||||
|| (battle_config.bone_drop==1 && map[sd->bl.m].flag.pvp)){ // ドクロドロップ
|
|| (battle_config.bone_drop==1 && map[sd->bl.m].flag.pvp)){ // ドクロドロップ
|
||||||
struct item item_tmp;
|
struct item item_tmp;
|
||||||
@ -6544,7 +6571,16 @@ int pc_setglobalreg(struct map_session_data *sd,char *reg,int val)
|
|||||||
if(strcmp(reg,"PC_DIE_COUNTER") == 0 && sd->die_counter != val){
|
if(strcmp(reg,"PC_DIE_COUNTER") == 0 && sd->die_counter != val){
|
||||||
sd->die_counter = val;
|
sd->die_counter = val;
|
||||||
pc_calcstatus(sd,0);
|
pc_calcstatus(sd,0);
|
||||||
|
} else if(strcmp(reg,"PCDieEvent") == 0){
|
||||||
|
sd->state.event_death = val;
|
||||||
|
} else if(strcmp(reg,"PCKillEvent") == 0){
|
||||||
|
sd->state.event_kill = val;
|
||||||
|
} else if(strcmp(reg,"PCLogoutEvent") == 0){
|
||||||
|
sd->state.event_disconnect = val;
|
||||||
|
} else if(strcmp(reg,"PCLoginEvent") == 0){
|
||||||
|
sd->state.event_onconnect = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(val==0){
|
if(val==0){
|
||||||
for(i=0;i<sd->status.global_reg_num;i++){
|
for(i=0;i<sd->status.global_reg_num;i++){
|
||||||
if(strcmp(sd->status.global_reg[i].str,reg)==0){
|
if(strcmp(sd->status.global_reg[i].str,reg)==0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user