Revert "status_change_timer refactorization"

This reverts commit 00d8ace8d8f1d2ab525e7b53dcae9cfcae32c638.
This commit is contained in:
Jey 2017-12-11 03:02:47 +01:00
parent 00d8ace8d8
commit d08bc1ce2d

View File

@ -12601,6 +12601,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
enum sc_type type = (sc_type)data; enum sc_type type = (sc_type)data;
struct block_list *bl; struct block_list *bl;
struct map_session_data *sd; struct map_session_data *sd;
struct status_data *status;
struct status_change *sc;
struct status_change_entry *sce;
int interval = status_get_sc_interval(type); int interval = status_get_sc_interval(type);
bool dounlock = false; bool dounlock = false;
@ -12609,19 +12612,14 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data); ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data);
return 0; return 0;
} }
sc = status_get_sc(bl);
status = status_get_status_data(bl);
struct status_change * const sc = status_get_sc(bl); if(!(sc && (sce = sc->data[type]))) {
struct status_data * const status = status_get_status_data(bl);
if(!sc) {
ShowDebug("status_change_timer: Null pointer id: %d data: %d bl-type: %d\n", id, data, bl->type); ShowDebug("status_change_timer: Null pointer id: %d data: %d bl-type: %d\n", id, data, bl->type);
return 0; return 0;
} }
struct status_change_entry * const sce = sc->data[type];
if(!sce) {
ShowDebug("status_change_timer: Null pointer id: %d data: %d bl-type: %d\n", id, data, bl->type);
return 0;
}
if( sce->timer != tid ) { if( sce->timer != tid ) {
ShowError("status_change_timer: Mismatch for type %d: %d != %d (bl id %d)\n",type,tid,sce->timer, bl->id); ShowError("status_change_timer: Mismatch for type %d: %d != %d (bl id %d)\n",type,tid,sce->timer, bl->id);
return 0; return 0;
@ -12629,16 +12627,19 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
sd = BL_CAST(BL_PC, bl); sd = BL_CAST(BL_PC, bl);
std::function<void (unsigned int)> sc_timer_next = [&sce, &bl, &data](unsigned int t) { // Set the next timer of the sce (don't assume the status still exists)
sce->timer = add_timer(t, status_change_timer, bl->id, data); #define sc_timer_next(t,f,i,d) \
}; if( (sce=sc->data[type]) ) \
sce->timer = add_timer(t,f,i,d); \
else \
ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data)
switch(type) { switch(type) {
case SC_MAXIMIZEPOWER: case SC_MAXIMIZEPOWER:
case SC_CLOAKING: case SC_CLOAKING:
if(!status_charge(bl, 0, 1)) if(!status_charge(bl, 0, 1))
break; // Not enough SP to continue. break; // Not enough SP to continue.
sc_timer_next(sce->val2+tick); sc_timer_next(sce->val2+tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC_CHASEWALK: case SC_CHASEWALK:
@ -12650,7 +12651,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_ROGUE?10:1) // SL bonus -> x10 duration (sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_ROGUE?10:1) // SL bonus -> x10 duration
*skill_get_time2(status_sc2skill(type),sce->val1)); *skill_get_time2(status_sc2skill(type),sce->val1));
} }
sc_timer_next(sce->val2+tick); sc_timer_next(sce->val2+tick, status_change_timer, bl->id, data);
return 0; return 0;
break; break;
@ -12660,7 +12661,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if(sce->val2 % sce->val4 == 0 && !status_charge(bl, 0, 1)) if(sce->val2 % sce->val4 == 0 && !status_charge(bl, 0, 1))
break; // Fail if it's time to substract SP and there isn't. break; // Fail if it's time to substract SP and there isn't.
sc_timer_next(1000+tick); sc_timer_next(1000+tick, status_change_timer,bl->id, data);
return 0; return 0;
} }
break; break;
@ -12680,14 +12681,14 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( --(sce->val2)>0 ) { if( --(sce->val2)>0 ) {
sce->val4 += 20; // Use for Shadow Form 2 seconds checking. sce->val4 += 20; // Use for Shadow Form 2 seconds checking.
sc_timer_next(20+tick); sc_timer_next(20+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_PROVOKE: case SC_PROVOKE:
if(sce->val2) { // Auto-provoke (it is ended in status_heal) if(sce->val2) { // Auto-provoke (it is ended in status_heal)
sc_timer_next(1000*60+tick); sc_timer_next(1000*60+tick,status_change_timer, bl->id, data );
return 0; return 0;
} }
break; break;
@ -12703,7 +12704,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
status_change_end(bl, SC_AETERNA, INVALID_TIMER); status_change_end(bl, SC_AETERNA, INVALID_TIMER);
sc->opt1 = OPT1_STONE; sc->opt1 = OPT1_STONE;
clif_changeoption(bl); clif_changeoption(bl);
sc_timer_next(min(sce->val4, interval) + tick); sc_timer_next(min(sce->val4, interval) + tick, status_change_timer, bl->id, data);
sce->val4 -= interval; //Remaining time sce->val4 -= interval; //Remaining time
status_calc_bl(bl, StatusChangeFlagTable[type]); status_calc_bl(bl, StatusChangeFlagTable[type]);
return 0; return 0;
@ -12818,7 +12819,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_TENSIONRELAX: case SC_TENSIONRELAX:
if(status->max_hp > status->hp && --(sce->val3) >= 0) { if(status->max_hp > status->hp && --(sce->val3) >= 0) {
sc_timer_next(10000 + tick); sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -12842,7 +12843,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( status->hp < status->max_hp ) if( status->hp < status->max_hp )
hp = (sce->val1 < 0) ? (int)(sd->status.max_hp * -1 * sce->val1 / 100.) : sce->val1 ; hp = (sce->val1 < 0) ? (int)(sd->status.max_hp * -1 * sce->val1 / 100.) : sce->val1 ;
status_heal(bl, hp, 0, 2); status_heal(bl, hp, 0, 2);
sc_timer_next((sce->val2 * 1000) + tick); sc_timer_next((sce->val2 * 1000) + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -12862,7 +12863,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
clif_bossmapinfo(sd, boss_md, BOSS_INFO_DEAD); clif_bossmapinfo(sd, boss_md, BOSS_INFO_DEAD);
} }
} }
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -12918,14 +12919,14 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if (!status_charge(bl, 0, sp)) if (!status_charge(bl, 0, sp))
break; break;
} }
sc_timer_next(1000+tick); sc_timer_next(1000+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_BERSERK: case SC_BERSERK:
// 5% every 10 seconds [DracoRPG] // 5% every 10 seconds [DracoRPG]
if( --( sce->val3 ) > 0 && status_charge(bl, sce->val2, 0) && status->hp > 100 ) { if( --( sce->val3 ) > 0 && status_charge(bl, sce->val2, 0) && status->hp > 100 ) {
sc_timer_next(sce->val4+tick); sc_timer_next(sce->val4+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -12936,7 +12937,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
clif_changestatus(sd,SP_MANNER,sd->status.manner); clif_changestatus(sd,SP_MANNER,sd->status.manner);
clif_updatestatus(sd,SP_MANNER); clif_updatestatus(sd,SP_MANNER);
if (sd->status.manner < 0) { // Every 60 seconds your manner goes up by 1 until it gets back to 0. if (sd->status.manner < 0) { // Every 60 seconds your manner goes up by 1 until it gets back to 0.
sc_timer_next(60000+tick); sc_timer_next(60000+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
} }
@ -12950,7 +12951,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
// clif_message(bl, timer); // clif_message(bl, timer);
// } // }
if((sce->val4 -= 500) > 0) { if((sce->val4 -= 500) > 0) {
sc_timer_next(500 + tick); sc_timer_next(500 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -12960,7 +12961,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
{ {
struct block_list *pbl = map_id2bl(sce->val1); struct block_list *pbl = map_id2bl(sce->val1);
if( pbl && check_distance_bl(bl, pbl, 7) ) { if( pbl && check_distance_bl(bl, pbl, 7) ) {
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
} }
@ -12973,35 +12974,35 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
sp = (sce->val1 > 5) ? 35 : 20; sp = (sce->val1 > 5) ? 35 : 20;
if(!status_charge(bl, hp, sp)) if(!status_charge(bl, hp, sp))
break; break;
sc_timer_next(10000+tick); sc_timer_next(10000+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_JAILED: case SC_JAILED:
if(sce->val1 == INT_MAX || --(sce->val1) > 0) { if(sce->val1 == INT_MAX || --(sce->val1) > 0) {
sc_timer_next(60000+tick); sc_timer_next(60000+tick, status_change_timer, bl->id,data);
return 0; return 0;
} }
break; break;
case SC_BLIND: case SC_BLIND:
if(sc->data[SC_FOGWALL]) { // Blind lasts forever while you are standing on the fog. if(sc->data[SC_FOGWALL]) { // Blind lasts forever while you are standing on the fog.
sc_timer_next(5000+tick); sc_timer_next(5000+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_ABUNDANCE: case SC_ABUNDANCE:
if(--(sce->val4) > 0) { if(--(sce->val4) > 0) {
status_heal(bl,0,60,0); status_heal(bl,0,60,0);
sc_timer_next(10000+tick); sc_timer_next(10000+tick, status_change_timer, bl->id, data);
} }
break; break;
case SC_OBLIVIONCURSE: case SC_OBLIVIONCURSE:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
clif_emotion(bl,ET_QUESTION); clif_emotion(bl,ET_QUESTION);
sc_timer_next(3000 + tick); sc_timer_next(3000 + tick, status_change_timer, bl->id, data );
return 0; return 0;
} }
break; break;
@ -13010,7 +13011,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
if( !status_charge(bl,0,3) ) if( !status_charge(bl,0,3) )
break; break;
sc_timer_next(5000+tick); sc_timer_next(5000+tick,status_change_timer,bl->id,data);
return 0; return 0;
} }
break; break;
@ -13018,7 +13019,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_CLOAKINGEXCEED: case SC_CLOAKINGEXCEED:
if(!status_charge(bl,0,10-sce->val1)) if(!status_charge(bl,0,10-sce->val1))
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC_RENOVATIO: case SC_RENOVATIO:
@ -13027,7 +13028,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( sc && sc->data[SC_AKAITSUKI] && heal ) if( sc && sc->data[SC_AKAITSUKI] && heal )
heal = ~heal + 1; heal = ~heal + 1;
status_heal(bl, heal, 0, 3); status_heal(bl, heal, 0, 3);
sc_timer_next(5000 + tick); sc_timer_next(5000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13040,7 +13041,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
if( !status_charge(bl, 0, 1) ) if( !status_charge(bl, 0, 1) )
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13052,13 +13053,13 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
status_change_end(bl, (sc_type)i, INVALID_TIMER); status_change_end(bl, (sc_type)i, INVALID_TIMER);
break; break;
} }
sc_timer_next(10000 + tick); sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC_ELECTRICSHOCKER: case SC_ELECTRICSHOCKER:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
status_charge(bl, 0, 5 * sce->val1 * status->max_sp / 100); status_charge(bl, 0, 5 * sce->val1 * status->max_sp / 100);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13068,20 +13069,20 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break; break;
if (--sce->val4 >= 0) if (--sce->val4 >= 0)
sce->val3++; sce->val3++;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC__REPRODUCE: case SC__REPRODUCE:
if(!status_charge(bl, 0, 1)) if(!status_charge(bl, 0, 1))
break; break;
sc_timer_next(1000+tick); sc_timer_next(1000+tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC__SHADOWFORM: case SC__SHADOWFORM:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
if( !status_charge(bl, 0, 11 - sce->val1) ) if( !status_charge(bl, 0, 11 - sce->val1) )
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13089,14 +13090,14 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC__INVISIBILITY: case SC__INVISIBILITY:
if( !status_charge(bl, 0, (12 - 2 * sce->val1) * status->max_sp / 100) ) // 6% - skill_lv. if( !status_charge(bl, 0, (12 - 2 * sce->val1) * status->max_sp / 100) ) // 6% - skill_lv.
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC_STRIKING: case SC_STRIKING:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
if( !status_charge(bl,0, sce->val3 ) ) if( !status_charge(bl,0, sce->val3 ) )
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13109,7 +13110,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
dounlock = true; dounlock = true;
skill_attack(skill_get_type(status_sc2skill(type)), src, unit_bl, bl, SO_CLOUD_KILL, sce->val1, tick, 0); skill_attack(skill_get_type(status_sc2skill(type)), src, unit_bl, bl, SO_CLOUD_KILL, sce->val1, tick, 0);
if (!status_isdead(bl)) { if (!status_isdead(bl)) {
sc_timer_next(500 + tick); sc_timer_next(500 + tick, status_change_timer, bl->id, data);
} }
} }
} }
@ -13127,7 +13128,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
hp = ~hp + 1; hp = ~hp + 1;
if (status->hp != status->max_hp) if (status->hp != status->max_hp)
status_heal(bl, hp, 0, 0); status_heal(bl, hp, 0, 0);
sc_timer_next(3000 + tick); sc_timer_next(3000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
@ -13145,7 +13146,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
status_damage(src, bl, damage, 0, clif_damage(bl,bl,tick,status->amotion,status->dmotion+200,damage,1,DMG_NORMAL,0,false), 0); status_damage(src, bl, damage, 0, clif_damage(bl,bl,tick,status->amotion,status->dmotion+200,damage,1,DMG_NORMAL,0,false), 0);
unit_skillcastcancel(bl,1); unit_skillcastcancel(bl,1);
if ( sc->data[type] ) { if ( sc->data[type] ) {
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
} }
map_freeblock_unlock(); map_freeblock_unlock();
status_heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level status_heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level
@ -13156,7 +13157,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_VOICEOFSIREN: case SC_VOICEOFSIREN:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
clif_emotion(bl,ET_THROB); clif_emotion(bl,ET_THROB);
sc_timer_next(2000 + tick); sc_timer_next(2000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13164,7 +13165,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_DEEPSLEEP: case SC_DEEPSLEEP:
if( --(sce->val4) >= 0 ) { // Recovers 3% HP/SP every 2 seconds. if( --(sce->val4) >= 0 ) { // Recovers 3% HP/SP every 2 seconds.
status_heal(bl, status->max_hp * 3 / 100, status->max_sp * 3 / 100, 2); status_heal(bl, status->max_hp * 3 / 100, status->max_sp * 3 / 100, 2);
sc_timer_next(2000 + tick); sc_timer_next(2000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13174,7 +13175,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( !status_charge(bl,0,sce->val3) ) if( !status_charge(bl,0,sce->val3) )
break; break;
status_heal(bl, sce->val2, 0, 1); status_heal(bl, sce->val2, 0, 1);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13182,7 +13183,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_SONGOFMANA: case SC_SONGOFMANA:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
status_heal(bl,0,sce->val3,3); status_heal(bl,0,sce->val3,3);
sc_timer_next(5000 + tick); sc_timer_next(5000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13193,7 +13194,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( --(sce->val3) >= 0 ) { if( --(sce->val3) >= 0 ) {
if( !status_charge(bl, status->hp / 100, status->sp / 100) ) if( !status_charge(bl, status->hp / 100, status->sp / 100) )
break; break;
sc_timer_next(sce->val4+tick); sc_timer_next(sce->val4+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13201,7 +13202,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_MELODYOFSINK: case SC_MELODYOFSINK:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
status_charge(bl, 0, status->max_sp * ( 2 * sce->val1 + 2 * sce->val2 ) / 100); status_charge(bl, 0, status->max_sp * ( 2 * sce->val1 + 2 * sce->val2 ) / 100);
sc_timer_next(1000+tick); sc_timer_next(1000+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13210,7 +13211,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( --(sce->val4) >= 0 ) { // Drains 2% of HP and 1% of SP every seconds. if( --(sce->val4) >= 0 ) { // Drains 2% of HP and 1% of SP every seconds.
if (!status_charge(bl, status->max_hp * 2 / 100, status->max_sp / 100)) if (!status_charge(bl, status->max_hp * 2 / 100, status->max_sp / 100))
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13218,13 +13219,13 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_FORCEOFVANGUARD: case SC_FORCEOFVANGUARD:
if( !status_charge(bl,0,24 - 4 * sce->val1) ) if( !status_charge(bl,0,24 - 4 * sce->val1) )
break; break;
sc_timer_next(10000 + tick); sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC_BANDING: case SC_BANDING:
if( status_charge(bl, 0, 7 - sce->val1) ) { if( status_charge(bl, 0, 7 - sce->val1) ) {
if( sd ) pc_banding(sd, sce->val1); if( sd ) pc_banding(sd, sce->val1);
sc_timer_next(5000 + tick); sc_timer_next(5000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13233,14 +13234,14 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( --(sce->val4) > 0 ) { if( --(sce->val4) > 0 ) {
if( !status_charge(bl,0,10) ) if( !status_charge(bl,0,10) )
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_OVERHEAT_LIMITPOINT: case SC_OVERHEAT_LIMITPOINT:
if( --(sce->val1) > 0 ) { // Cooling if( --(sce->val1) > 0 ) { // Cooling
sc_timer_next(30000 + tick); sc_timer_next(30000 + tick, status_change_timer, bl->id, data);
} }
break; break;
@ -13251,7 +13252,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
map_freeblock_lock(); map_freeblock_lock();
status_fix_damage(NULL,bl,damage,clif_damage(bl,bl,tick,0,0,damage,0,DMG_NORMAL,0,false)); status_fix_damage(NULL,bl,damage,clif_damage(bl,bl,tick,0,0,damage,0,DMG_NORMAL,0,false));
if( sc->data[type] ) { if( sc->data[type] ) {
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
} }
map_freeblock_unlock(); map_freeblock_unlock();
} }
@ -13265,7 +13266,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break; break;
if (!status_charge(bl, 0, 50)) if (!status_charge(bl, 0, 50))
status_zap(bl, 0, status->sp); status_zap(bl, 0, status->sp);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13277,7 +13278,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( !status_charge(bl,hp,sp) ) break; if( !status_charge(bl,hp,sp) ) break;
sc_timer_next(5000+tick); sc_timer_next(5000+tick,status_change_timer,bl->id, data);
return 0; return 0;
} }
break; break;
@ -13286,7 +13287,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
// 1% every 5 seconds [Jobbie] // 1% every 5 seconds [Jobbie]
if( --(sce->val3)>0 && status_charge(bl, sce->val2, 0) ) { if( --(sce->val3)>0 && status_charge(bl, sce->val2, 0) ) {
if( !sc->data[type] ) return 0; if( !sc->data[type] ) return 0;
sc_timer_next(5000 + tick); sc_timer_next(5000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13320,12 +13321,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
status_change_end(bl,type,INVALID_TIMER); status_change_end(bl,type,INVALID_TIMER);
break; break;
} }
sc_timer_next(sce->val3 + tick); sc_timer_next(sce->val3 + tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC_WATER_SCREEN_OPTION: case SC_WATER_SCREEN_OPTION:
status_heal(bl,1000,0,2); status_heal(bl,1000,0,2);
sc_timer_next(10000 + tick); sc_timer_next(10000 + tick,status_change_timer,bl->id,data);
return 0; return 0;
case SC_TEARGAS: case SC_TEARGAS:
@ -13337,7 +13338,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
clif_damage(bl, bl, tick, 0, 0, damage, 1, DMG_MULTI_HIT_ENDURE, 0, false); clif_damage(bl, bl, tick, 0, 0, damage, 1, DMG_MULTI_HIT_ENDURE, 0, false);
status_damage(src, bl, damage,0, 0, 1); status_damage(src, bl, damage,0, 0, 1);
if( sc->data[type] ) { if( sc->data[type] ) {
sc_timer_next(2000 + tick); sc_timer_next(2000 + tick, status_change_timer, bl->id, data);
} }
map_freeblock_unlock(); map_freeblock_unlock();
return 0; return 0;
@ -13346,7 +13347,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_TEARGAS_SOB: case SC_TEARGAS_SOB:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
clif_emotion(bl, ET_CRY); clif_emotion(bl, ET_CRY);
sc_timer_next(3000 + tick); sc_timer_next(3000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13358,7 +13359,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
skill_sit(sd, 1); skill_sit(sd, 1);
clif_sitting(bl); clif_sitting(bl);
} }
sc_timer_next(10000 + tick); sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13367,26 +13368,26 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_SOULCOLD: case SC_SOULCOLD:
case SC_HAWKEYES: case SC_HAWKEYES:
// They only end by status_change_end // They only end by status_change_end
sc_timer_next(600000 + tick); sc_timer_next(600000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
case SC_MEIKYOUSISUI: case SC_MEIKYOUSISUI:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
status_heal(bl, status->max_hp * sce->val2 / 100, status->max_sp * sce->val3 / 100, 0); status_heal(bl, status->max_hp * sce->val2 / 100, status->max_sp * sce->val3 / 100, 0);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_KAGEMUSYA: case SC_KAGEMUSYA:
if( --(sce->val2) >= 0 ) { if( --(sce->val2) >= 0 ) {
if(!status_charge(bl, 0, 1)) break; if(!status_charge(bl, 0, 1)) break;
sc_timer_next(1000+tick); sc_timer_next(1000+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_ANGRIFFS_MODUS: case SC_ANGRIFFS_MODUS:
if(--(sce->val4) >= 0) { // Drain hp/sp if(--(sce->val4) >= 0) { // Drain hp/sp
if( !status_charge(bl,100,20) ) break; if( !status_charge(bl,100,20) ) break;
sc_timer_next(1000+tick); sc_timer_next(1000+tick,status_change_timer,bl->id, data);
return 0; return 0;
} }
break; break;
@ -13396,35 +13397,35 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
int sp = (status->max_sp * sce->val3) / 100; int sp = (status->max_sp * sce->val3) / 100;
if(bl->type == BL_MOB) hp = sp*10; if(bl->type == BL_MOB) hp = sp*10;
if( !status_charge(bl,hp,sp) )break; if( !status_charge(bl,hp,sp) )break;
sc_timer_next(1000+tick); sc_timer_next(1000+tick,status_change_timer,bl->id, data);
return 0; return 0;
} }
break; break;
case SC_FULL_THROTTLE: case SC_FULL_THROTTLE:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
status_percent_damage(bl, bl, 0, sce->val2, false); status_percent_damage(bl, bl, 0, sce->val2, false);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_REBOUND: case SC_REBOUND:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
clif_emotion(bl, ET_SWEAT); clif_emotion(bl, ET_SWEAT);
sc_timer_next(2000 + tick); sc_timer_next(2000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_KINGS_GRACE: case SC_KINGS_GRACE:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
status_percent_heal(bl, sce->val2, 0); status_percent_heal(bl, sce->val2, 0);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_FRIGG_SONG: case SC_FRIGG_SONG:
if( --(sce->val4) >= 0 ) { if( --(sce->val4) >= 0 ) {
status_heal(bl, sce->val3, 0, 0); status_heal(bl, sce->val3, 0, 0);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13433,7 +13434,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
TBL_PC *caster = map_id2sd(sce->val2); TBL_PC *caster = map_id2sd(sce->val2);
if (!caster || caster->bl.m != bl->m) //End the SC if caster isn't in same map if (!caster || caster->bl.m != bl->m) //End the SC if caster isn't in same map
break; break;
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
clif_crimson_marker(caster, bl, false); clif_crimson_marker(caster, bl, false);
return 0; return 0;
} }
@ -13442,7 +13443,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if (--(sce->val4) >= 0) { if (--(sce->val4) >= 0) {
if (!status_charge(bl, 0, status->max_sp * 3 / 100)) if (!status_charge(bl, 0, status->max_sp * 3 / 100))
break; break;
sc_timer_next(sce->val3 + tick); sc_timer_next(sce->val3 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13452,21 +13453,21 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
clif_slide(bl, sce->val3>>16, sce->val3&0xFFFF); clif_slide(bl, sce->val3>>16, sce->val3&0xFFFF);
clif_fixpos(bl); clif_fixpos(bl);
} }
sc_timer_next(tick+sce->val4); sc_timer_next(tick+sce->val4, status_change_timer, bl->id, data);
sce->val4 = 0; sce->val4 = 0;
} }
break; break;
case SC_BITESCAR: case SC_BITESCAR:
if (--(sce->val4) >= 0) { if (--(sce->val4) >= 0) {
status_percent_damage(bl, bl, -(sce->val2), 0, 0); status_percent_damage(bl, bl, -(sce->val2), 0, 0);
sc_timer_next(1000 + tick); sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_FRESHSHRIMP: case SC_FRESHSHRIMP:
if (--(sce->val4) >= 0) { if (--(sce->val4) >= 0) {
status_heal(bl, sce->val2, 0, 3); status_heal(bl, sce->val2, 0, 3);
sc_timer_next((10000 - ((sce->val1 - 1) * 1000)) + tick); sc_timer_next((10000 - ((sce->val1 - 1) * 1000)) + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13474,7 +13475,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( sd && --(sce->val4) >= 0 ) { if( sd && --(sce->val4) >= 0 ) {
if( status->hp < status->max_hp ) if( status->hp < status->max_hp )
status_heal(bl, 10, 0, 2); status_heal(bl, 10, 0, 2);
sc_timer_next(10000 + tick); sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13482,7 +13483,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( sd && --(sce->val4) >= 0 ) { if( sd && --(sce->val4) >= 0 ) {
if( status->sp < status->max_sp ) if( status->sp < status->max_sp )
status_heal(bl, 0, 5, 2); status_heal(bl, 0, 5, 2);
sc_timer_next(10000 + tick); sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
@ -13490,7 +13491,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
// If status has an interval and there is at least 100ms remaining time, wait for next interval // If status has an interval and there is at least 100ms remaining time, wait for next interval
if(interval > 0 && sc->data[type] && sce->val4 >= 100) { if(interval > 0 && sc->data[type] && sce->val4 >= 100) {
sc_timer_next(min(sce->val4,interval)+tick); sc_timer_next(min(sce->val4,interval)+tick, status_change_timer, bl->id, data);
sce->val4 -= interval; sce->val4 -= interval;
if (dounlock) if (dounlock)
map_freeblock_unlock(); map_freeblock_unlock();
@ -13502,6 +13503,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
// Default for all non-handled control paths is to end the status // Default for all non-handled control paths is to end the status
return status_change_end( bl,type,tid ); return status_change_end( bl,type,tid );
#undef sc_timer_next
} }
/** /**