viewing paste fun_acrobats | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/* Starts a status effect on the target unit or on the attached player.
 *
 * sc_start  <effect_id>,<duration>,<val1>{,<rate>,<flag>,{<unit_id>}};
 * sc_start2 <effect_id>,<duration>,<val1>,<val2>{,<rate,<flag>,{<unit_id>}};
 * sc_start4 <effect_id>,<duration>,<val1>,<val2>,<val3>,<val4>{,<rate,<flag>,{<unit_id>}};
 * <flag>
 *      &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;
 
        type = (sc_type)script_getnum(st,2);
        tick = script_getnum(st,3);
        val1 = script_getnum(st,4);
 
        rate = script_hasdata(st,(4+script_lastdata(st)-2))?min(script_getnum(st,(4+script_lastdata(st)-2)),10000):10000;
        flag = script_hasdata(st,(5+script_lastdata(st)-2))?script_getnum(st,(5+script_lastdata(st)-2)):2;
 
        if(script_hasdata(st,(6+script_lastdata(st)-2)))
                bl = map_id2bl(script_getnum(st,(6+script_lastdata(st)-2)));
        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(script_lastdata(st)-2) {
                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 3:
                        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;
}
Viewed 247 times, submitted by unknown.