summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-05 09:31:09 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-05 09:31:09 +0000
commit00c27a50bd63163a0de9cf4f7aefd3b60e8aa5d0 (patch)
tree5d60988f58a7dd4dd8d1c8eb57b6651484538088
parente80324069deac5943aa9d7685b32198407c424bc (diff)
downloadhercules-00c27a50bd63163a0de9cf4f7aefd3b60e8aa5d0.tar.gz
hercules-00c27a50bd63163a0de9cf4f7aefd3b60e8aa5d0.tar.bz2
hercules-00c27a50bd63163a0de9cf4f7aefd3b60e8aa5d0.tar.xz
hercules-00c27a50bd63163a0de9cf4f7aefd3b60e8aa5d0.zip
Added a simplified version of Qamera's OnConnect: OnDisconnect: OnDeath: NPC events mod
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@914 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog.txt14
-rw-r--r--src/map/map.c8
-rw-r--r--src/map/map.h5
-rw-r--r--src/map/pc.c38
4 files changed, 64 insertions, 1 deletions
diff --git a/Changelog.txt b/Changelog.txt
index 20d854ae2..e15d10b41 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,5 +1,19 @@
Date Added
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]
* Set 'droprate0item''s default to 'yes' so that items with 0 rate will never
drop [celest]
diff --git a/src/map/map.c b/src/map/map.c
index 0ba13519f..7d82bc40c 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -969,6 +969,14 @@ void map_addnickdb(struct map_session_data *sd) {
int map_quit(struct map_session_data *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) // チャットから出る
chat_leavechat(sd);
diff --git a/src/map/map.h b/src/map/map.h
index 7f3fa5d71..289e8338b 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -143,6 +143,11 @@ struct map_session_data {
int glorywounds_flag;
int soulcold_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;
struct {
unsigned killer : 1;
diff --git a/src/map/pc.c b/src/map/pc.c
index 0586e7a9e..14ee9b097 100644
--- a/src/map/pc.c
+++ b/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->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) {
char tmpstr[1024];
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);
ShowInfo(tmp_output);
- {
+ if (sd->state.event_onconnect) {
struct npc_data *npc;
//printf("pc: OnPCLogin event done. (%d events)\n", npc_event_doall("OnPCLogin") );
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);
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
|| (battle_config.bone_drop==1 && map[sd->bl.m].flag.pvp)){ // ドクロドロップ
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){
sd->die_counter = val;
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){
for(i=0;i<sd->status.global_reg_num;i++){
if(strcmp(sd->status.global_reg[i].str,reg)==0){