summaryrefslogblamecommitdiff
path: root/world/map/npc/042-2/barrels_config.txt
blob: 85c78e41d932d455045a30fb5c171a7a64184ba7 (plain) (tree)












































































































                                                                                                                                                                                    
// Barrels
// Author: Wushin
042-2.gat,33,88,24,7|monster|HouseMaggot|1050,2,100000,30000,Barrel#0::OnMaggotDeath
-|script|#BarrelConfig|-1,
{
    end;

OnInit:
    set $@BarrelStartBit, (1 << 16);
    set $@BarrelEndBit, (1 << 23);
    set $@ZegasMetBit, (1 << 30);
    setarray $@BarrelBits, (1 << 17), (1 << 18), (1 << 19), (1 << 20), (1 << 21), (1 << 22);
    setarray $@BarrelRewards, 533, 507, 505, 518, 537, 526;
    set $@BarrelSpawnCnt, 1;
    set $@BarrelSpawnId, 1050;
    set $@BarrelSpawnName$, "House Maggot";
    set $@BarrelMax, getarraysize($@BarrelBits);
    end;

}
function|script|CheckBarrelQuest|,
{
    callfunc "CountBarrels";
    set @barrel_quest, 0;
    if (TUTORIAL & $@ZegasMetBit)
        set @barrel_quest, 1;
    if (TUTORIAL & $@BarrelStartBit)
        set @barrel_quest, 2;
    if (!(TUTORIAL & $@BarrelStartBit) && (@barrel_count))
        set @barrel_quest, 3;
    if (TUTORIAL & $@BarrelEndBit)
        set @barrel_quest, 4;
    return;
}
function|script|CountBarrels|,
{
    set @barrel_count, 0;
    set @barrel_tmp, 0;
    goto L_Loop;

L_Loop:    
    if (TUTORIAL & $@BarrelBits[@barrel_tmp])
        goto L_AddOne;
    goto L_LoopAgain;

L_AddOne:
    set @barrel_count, (@barrel_count + 1);
    goto L_LoopAgain;

L_LoopAgain:
    set @barrel_tmp, (@barrel_tmp + 1);
    if (@barrel_tmp == getarraysize($@BarrelBits))
        goto L_BarrelTally;
    goto L_Loop;

L_BarrelTally:
    return;
}
function|script|CheckBarrel|,
{
    callfunc "PCtoNPCRange";
    if (@npc_check)
        goto L_Range;
    callfunc "CheckBarrelQuest";
    if (!(@barrel_quest))
        goto L_NoI;
    if (TUTORIAL & $@BarrelBits[@barrel])
        goto L_Empty;
    set TUTORIAL, TUTORIAL | $@BarrelBits[@barrel];

    callfunc "CountBarrels";
    if (@barrel_count == $@BarrelMax)
        goto L_QuestReward;
    set @player_random, rand(@barrel_count * 10);
    set @barrel_random, rand(@barrel_count * $@BarrelMax);
    if (@barrel_random > @player_random)
        goto L_Spawn;
    goto L_Reward;

L_Range:
    message strcharinfo(0), "You'll need to get closer.";
    goto L_Return;

L_NoI:
    message strcharinfo(0), "Nothing interesting here.";
    goto L_Return;

L_Empty:
    message strcharinfo(0), "You've already searched this barrel.";
    goto L_Return;

L_QuestReward:
    message strcharinfo(0), "You found the bug bomb.";
    misceffect 33;
    set TUTORIAL, TUTORIAL &~ $@BarrelStartBit;
    killmonster getmap() + ".gat", "Barrel#0::OnMaggotDeath";
    goto L_Return;

L_Spawn:
    areamonster getmap() + ".gat", @npc_loc[0], @npc_loc[1], (@npc_loc[0] + 1), (@npc_loc[1] + 1), $@BarrelSpawnName$, $@BarrelSpawnId, $@BarrelSpawnCnt, "Barrel#0::OnMaggotDeath";
    goto L_Return;

L_Reward:
    getitem $@BarrelRewards[rand(getarraysize($@BarrelRewards))], 1;
    goto L_Return;

L_Return:
    return;
}