summaryrefslogtreecommitdiff
path: root/npc/008-3-5/lordcave.txt
blob: 906cd8adf93468b2f4eb40dcb8078ce445bf5bd7 (plain) (blame)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// TMW2 Script
// Author:
//    Jesusalva
// FIXME:
//    Create a party instance for this

008-3-5,83,49,0	script	#BanditLordDen	NPC_HIDDEN,0,5,{
    function lordCleanup;
    end;

function lordCleanup {
    // Bug
    if (!.lock) {
        consolemes(CONSOLEMES_ERROR, "No lock passed to Lord Cave during cleanup");
        end;
    }

    // Cleanup
    .lock = false;
    delcells "BanditLordDenWall";
    killmonster("008-3-5", "#BanditLordDen::OnLordDeath");
    stopnpctimer;
    return;
}

OnInit:
    .maxLevel = 55;
    .lock=false;
    end;

OnTouch:
    .@q=getq(HurnscaldQuest_Bandits);
    if (.@q != 6) end;

    // Oooh, we got a challenger!

    // But the Lord is busy? Oh well, try again later
    if (.lock) {
        dispbottom l("%s came here first, you should wait for them.", strcharinfo(0, "Someone", .lock));
        slide 92, 52;
        end;
    }

    // Block the NPC
    .lock=getcharid(3);
    slide 80, 49;

    // Block the passage
    mapannounce "008-3-5", "A minor earthquake happens.", bc_map;
    setcells "008-3-5", 82, 48, 83, 51, 2, "BanditLordDenWall";
    initnpctimer;

    // Summon
    if (mobcount("008-3-5", "#BanditLordDen::OnLordDeath") == 0)
        monster "008-3-5", 48, 35, "Bandit Lord", BanditLord, 1, "#BanditLordDen::OnLordDeath";
    end;

OnLordDeath:
    // Unlock
    lordCleanup();

    // If killed by a monster, GM, whatever, abort
    if (!playerattached())
        end;

    // Complete quest (if PC is attached and doing quest)
    .@q=getq(HurnscaldQuest_Bandits);
    if (.@q == 6 && !ispcdead()) {
        setq HurnscaldQuest_Bandits, 7;
        quest_xp(.maxLevel, 2500);
        dispbottom l("Phew! The Bandit Lord was killed.");
    } else {
        dispbottom l("I killed the Bandit Lord! ...Why I did that, again?");
    }
    end;

OnTimer5000:
    .@pc=attachrid(.lock);

    // Player logged out
    if (!.@pc) {
        lordCleanup();
        end;
    }

    // Player killed in combat
    if (ispcdead()) {
        lordCleanup();
        end;
    }

    // Player changed map
    if (getmap() != "008-3-5") {
        lordCleanup();
        end;
    }

    // Battle ongoing, restart timer
    initnpctimer;
    end;
}