/* Starts a status effect on the target unit or on the attached player. * * sc_start ,,{,,,{}}; * sc_start2 ,,,{,,{}}; * sc_start4 ,,,,,{,,{}}; * * &1: Cannot be avoided (it has to start) * &2: Tick should not be reduced (by vit, luk, lv, etc) * &4: sc_data loaded, no value has to be altered. * &8: rate should not be reduced */ BUILDIN_FUNC(sc_start) { struct block_list* bl; enum sc_type type; int tick, val1, val2, val3, rate, flag; int val4 = 0; char command; if(strstr(script_getstr(st,1), "2")) command = 2; else if(strstr(script_getstr(st,1), "4")) command = 4; else command = 1; type = (sc_type)script_getnum(st,2); tick = script_getnum(st,3); val1 = script_getnum(st,4); rate = script_hasdata(st,4+command)?min(script_getnum(st,4+command),10000):10000; flag = script_hasdata(st,5+command)?script_getnum(st,5+command):2; if(script_hasdata(st,(6+command))) bl = map_id2bl(script_getnum(st,(6+command))); else bl = map_id2bl(st->rid); if(tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0) {// When there isn't a duration specified, try to get it from the skill_db tick = skill_get_time(status_sc2skill(type), val1); } if(potion_flag == 1 && potion_target) { //skill.c set the flags before running the script, this is a potion-pitched effect. bl = map_id2bl(potion_target); tick /= 2;// Thrown potions only last half. val4 = 1;// Mark that this was a thrown sc_effect } switch(command) { case 1: if(bl) status_change_start(NULL, bl, type, rate, val1, 0, 0, val4, tick, flag); break; case 2: val2 = script_getnum(st,5); if(bl) status_change_start(NULL, bl, type, rate, val1, val2, 0, val4, tick, flag); break; case 4: val2 = script_getnum(st,5); val3 = script_getnum(st,6); val4 = script_getnum(st,7); if(bl) status_change_start(NULL, bl, type, rate, val1, val2, val3, val4, tick, flag); break; } return 0; }