Scofield Posted October 17, 2014 Group: Members Topic Count: 109 Topics Per Day: 0.02 Content Count: 272 Reputation: 16 Joined: 01/11/13 Last Seen: 12 hours ago Share Posted October 17, 2014 (edited) I'm using eAthena and my Map server crashes when the monster is respawned... can you help me about this? or @reloadscript Index: conf/battle/monster.conf =================================================================== --- conf/battle/monster.conf (revision 15090) +++ conf/battle/monster.conf (working copy) @@ -213,3 +213,7 @@ // Should MVP slaves retain their target when summoned back to their master? mob_slave_keep_target: yes + +// Wheter or not to spawn the mvp tomb. +// See http://irowiki.org/wiki/MVP#Gravestone +mvp_tomb_enabled: yes \ No newline at end of file Index: conf/msg_athena.conf =================================================================== --- conf/msg_athena.conf (revision 15090) +++ conf/msg_athena.conf (working copy) @@ -535,5 +535,17 @@ //... 650: Unknown Job +// MvP Tomb +// Added here so it can be easily translated +656: Tomb +657: [ ^EE0000%s^000000 ] +658: Has met its demise +659: Time of death : ^EE0000%s^000000 +660: Defeated by +661: [^EE0000%s^000000] +// Added features [malufett] +900: Time of respawn: ^EE0000%s^000000 +901: Time left: %02i:%02i:%02i + //Custom translations import: conf/import/msg_conf.txt Index: src/map/battle.c =================================================================== --- src/map/battle.c (revision 15090) +++ src/map/battle.c (working copy) @@ -4023,6 +4023,7 @@ { "bg_magic_attack_damage_rate", &battle_config.bg_magic_damage_rate, 60, 0, INT_MAX, }, { "bg_misc_attack_damage_rate", &battle_config.bg_misc_damage_rate, 60, 0, INT_MAX, }, { "bg_flee_penalty", &battle_config.bg_flee_penalty, 20, 0, INT_MAX, }, + { "mvp_tomb_enabled", &battle_config.mvp_tomb_enabled, 1, 0, 1, }, }; Index: src/map/battle.h =================================================================== --- src/map/battle.h (revision 15090) +++ src/map/battle.h (working copy) @@ -497,6 +497,8 @@ int bg_magic_damage_rate; int bg_misc_damage_rate; int bg_flee_penalty; + + int mvp_tomb_enabled; } battle_config; void do_init_battle(void); Index: src/map/map.h =================================================================== --- src/map/map.h (revision 15090) +++ src/map/map.h (working copy) @@ -199,7 +199,7 @@ //For common mapforeach calls. Since pets cannot be affected, they aren't included here yet. #define BL_CHAR (BL_PC|BL_MOB|BL_HOM|BL_MER) -enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP }; +enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, TOMB }; enum { RC_FORMLESS=0, Index: src/map/mob.c =================================================================== --- src/map/mob.c (revision 15090) +++ src/map/mob.c (working copy) @@ -33,6 +33,7 @@ #include "atcommand.h" #include "date.h" #include "quest.h" +#include "chat.h" #include <stdio.h> #include <stdlib.h> @@ -115,6 +116,88 @@ } /*========================================== + * MvP Tomb [GreenBox] + *------------------------------------------*/ +void mvptomb_create(struct mob_data *md, char *killer, time_t time) +{ + struct npc_data *nd; + const struct TimerData * timer_data = get_timer(md->spawn_timer); + + CREATE(nd, struct npc_data, 1); + + nd->bl.id = md->tomb_nid = npc_get_new_npc_id(); + + nd->ud.dir = md->ud.dir; + nd->bl.m = md->bl.m; + nd->bl.x = md->bl.x; + nd->bl.y = md->bl.y; + nd->bl.type = BL_NPC; + + safestrncpy(nd->name, msg_txt(656), sizeof(nd->name)); + + nd->class_ = 565; + nd->speed = 200; + nd->subtype = TOMB; + + nd->u.tomb.md = md; + nd->u.tomb.kill_time = time; + nd->u.tomb.spawn_time = nd->u.tomb.spawn_timer = (DIFF_TICK(timer_data->tick, gettick()) + 60); + + if (killer) + safestrncpy(nd->u.tomb.killer_name, killer, NAME_LENGTH); + else + nd->u.tomb.killer_name[0] = '\0'; + + map_addnpc(nd->bl.m, nd); + map_addblock(&nd->bl); + status_set_viewdata(&nd->bl, nd->class_); + status_change_init(&nd->bl); + unit_dataset(&nd->bl); + clif_spawn(&nd->bl); + + add_timer(gettick()+1000, mob_tombtimer, nd->bl.id, 0); +} + +/** + MVP Tomb Added Features + -Show time left before respawning [malufett] +**/ +int mob_tombtimer(int tid, unsigned int tick, int id, intptr_t data) +{ + struct npc_data *nd = (struct npc_data *)map_id2bl(id); + int ms = nd->u.tomb.spawn_timer, hour=0, min=0, sec=0; + + if( nd && ms > 0) + { + char w1[256]; + + hour = ms / 3600000; + min = ms % 3600000 / 60000; + sec = ms % 60000 / 1000; + + sprintf(w1, msg_txt(901), hour , min, sec); + + chat_deletenpcchat(nd); + chat_createnpcchat(nd, w1, 0, 0, 1, "", 0, 1, MAX_LEVEL); + + add_timer(gettick()+1000, mob_tombtimer, id, 0); + nd->u.tomb.spawn_timer -= 1000; + }else + chat_deletenpcchat(nd); + + return 0; +} + +void mvptomb_destroy(struct mob_data *md) +{ + struct npc_data *nd = (struct npc_data *)map_id2bl(md->tomb_nid); + if (nd) + npc_unload(nd); + + md->tomb_nid = 0; +} + +/*========================================== * Founds up to N matches. Returns number of matches [Skotlex] *------------------------------------------*/ int mobdb_searchname_array(struct mob_db** data, int size, const char *str) @@ -804,6 +887,13 @@ if( md->spawn_timer != INVALID_TIMER ) delete_timer(md->spawn_timer, mob_delayspawn); md->spawn_timer = add_timer(gettick()+spawntime, mob_delayspawn, md->bl.id, 0); + + // MvP tomb [GreenBox] + if (battle_config.mvp_tomb_enabled && md->spawn->state.boss){ + struct map_session_data *mvp_sd = map_id2sd(md->target_id); + mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); + } + return 0; } @@ -890,6 +980,10 @@ // Added for carts, falcons and pecos for cloned monsters. [Valaris] md->sc.option = md->db->option; + // MvP tomb [GreenBox] + if (md->tomb_nid) + mvptomb_destroy(md); + map_addblock(&md->bl); clif_spawn(&md->bl); skill_unit_move(&md->bl,tick,1); @@ -2446,6 +2540,9 @@ if(!md->spawn) //Tell status_damage to remove it from memory. return 5; // Note: Actually, it's 4. Oh well... + if (battle_config.mvp_tomb_enabled && md->spawn->state.boss) + md->target_id = mvp_sd->bl.id; + if( !rebirth ) mob_setdelayspawn(md); //Set respawning. return 3; //Remove from map. @@ -4334,6 +4431,8 @@ add_timer_interval(gettick()+MIN_MOBTHINKTIME,mob_ai_hard,0,0,MIN_MOBTHINKTIME); add_timer_interval(gettick()+MIN_MOBTHINKTIME*10,mob_ai_lazy,0,0,MIN_MOBTHINKTIME*10); + add_timer_func_list(mob_tombtimer,"mob_tombtimer");// [malufett] + return 0; } @@ -4367,4 +4466,4 @@ ers_destroy(item_drop_ers); ers_destroy(item_drop_list_ers); return 0; -} +} \ No newline at end of file Index: src/map/mob.h =================================================================== --- src/map/mob.h (revision 15090) +++ src/map/mob.h (working copy) @@ -161,6 +161,8 @@ short skillidx; unsigned int skilldelay[MAX_MOBSKILL]; char npc_event[EVENT_NAME_LENGTH]; + + int tomb_nid; }; @@ -277,6 +279,11 @@ int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char *event, int master_id, int mode, int flag, unsigned int duration); int mob_clone_delete(struct mob_data *md); +// MvP Tomb System +void mvptomb_create(struct mob_data *md, char *killer, time_t time); +void mvptomb_destroy(struct mob_data *md); +int mob_tombtimer(int tid, unsigned int tick, int id, intptr_t data); + void mob_reload(void); #endif /* _MOB_H_ */ Index: src/map/npc.c =================================================================== --- src/map/npc.c (revision 15090) +++ src/map/npc.c (working copy) @@ -27,6 +27,7 @@ #include "unit.h" #include "npc.h" #include "chat.h" +#include "atcommand.h" #include <stdio.h> #include <stdlib.h> @@ -1087,6 +1088,8 @@ case SCRIPT: run_script(nd->u.scr.script,0,sd->bl.id,nd->bl.id); break; + case TOMB: + run_tomb(sd,nd); } return 0; @@ -2634,6 +2637,48 @@ clif_spawn(&nd->bl);// fade in } +// MvP tomb [GreenBox] +void run_tomb(struct map_session_data* sd, struct npc_data* nd) +{ + char buffer[200]; + char time[10]; + struct tm *newtime = localtime(&nd->u.tomb.kill_time); + + strftime(time, sizeof(time), "%H:%M", newtime); + + // TODO: Find exact color? + snprintf(buffer, sizeof(buffer), msg_txt(657), nd->u.tomb.md->db->name); + clif_scriptmes(sd, nd->bl.id, buffer); + + clif_scriptmes(sd, nd->bl.id, msg_txt(658)); + + snprintf(buffer, sizeof(buffer), msg_txt(659), time); + clif_scriptmes(sd, nd->bl.id, buffer); + + /** MVP Tomb added features + -Show time of respawn [malufett] + **/ + if(nd->u.tomb.spawn_time != INVALID_TIMER){ + int ms = nd->u.tomb.spawn_time; + newtime->tm_hour += ms % 86400000 / 3600000; + newtime->tm_min += ms % 3600000 / 60000 + 1; + if(newtime->tm_min>59){ + newtime->tm_hour++; + newtime->tm_min -= 60; + } + strftime(time, sizeof(time), "%H:%M", newtime); + snprintf(buffer, sizeof(buffer), msg_txt(900), time); + clif_scriptmes(sd, nd->bl.id, buffer); + } + + clif_scriptmes(sd, nd->bl.id, msg_txt(660)); + + snprintf(buffer, sizeof(buffer), msg_txt(661), nd->u.tomb.killer_name[0] ? nd->u.tomb.killer_name : "Unknown"); + clif_scriptmes(sd, nd->bl.id, buffer); + + clif_scriptclose(sd, nd->bl.id); +} + /// Parses a function. /// function%TAB%script%TAB%<function name>%TAB%{<code>} static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) Index: src/map/npc.h =================================================================== --- src/map/npc.h (revision 15090) +++ src/map/npc.h (working copy) @@ -62,6 +62,13 @@ short x,y; // destination coords unsigned short mapindex; // destination map } warp; + struct { + struct mob_data *md; + time_t kill_time; + char killer_name[NAME_LENGTH]; + int spawn_time; //malufett + int spawn_timer; + } tomb; } u; }; @@ -155,6 +162,8 @@ int npc_duplicate4instance(struct npc_data *snd, int m); int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points); +void run_tomb(struct map_session_data* sd, struct npc_data* nd); + extern struct npc_data* fake_nd; #endif /* _NPC_H_ */ Index: src/map/unit.c =================================================================== --- src/map/unit.c (revision 15090) +++ src/map/unit.c (working copy) @@ -2215,6 +2215,9 @@ } if( mob_is_clone(md->class_) ) mob_clone_delete(md); + if( md->tomb_nid ) + mvptomb_destroy(md); + break; } case BL_HOM: Edited October 21, 2014 by cumbe11 Quote Link to comment Share on other sites More sharing options...
Scofield Posted October 18, 2014 Group: Members Topic Count: 109 Topics Per Day: 0.02 Content Count: 272 Reputation: 16 Joined: 01/11/13 Last Seen: 12 hours ago Author Share Posted October 18, 2014 up Quote Link to comment Share on other sites More sharing options...
Question
Scofield
I'm using eAthena and my Map server crashes when the monster is respawned... can you help me about this?
Edited by cumbe11or @reloadscript
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.