summaryrefslogtreecommitdiff
path: root/npc/006-2-6/hatchling.txt
blob: df06409ebbe08f98341e2357d0a3f8a810ca3534 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Evol scripts.
// Author:
//    Travolta
//	  +seeds
// Description:
//    A piou hatchling who escaped his nurse and fled to the castle. He's been terrorizing the staff.
// Variables:
//    none

function	script	ArtisFlyingPiouLogic	{
    .@tick = gettimetick(1);
    .@LastTimeTouched = getvariableofnpc(.LastTimeTouched, strnpcinfo(3));
    if (.@tick > .@LastTimeTouched + 300)
    {
        .speed = 200;
        set getvariableofnpc(.LastPlayerTouched, strnpcinfo(3)), -1;
    }
    .@rnd = rand(5) - 3;
    if (.@rnd > 0)
        return execmovecmd("wait " + .@rnd);
    return 0;
}

006-2-6,38,28,0	script	#Hatchling	NPC_FLYING_PIOU,{
	.@q=getq(LilitQuest_Hatchling);
    function  TryCatchPiou {
        .@agi = readparam(bAgi);
        @ArtisQuests_CatchPiouTries += 1;
        getmapxy(.@map$, .@x1, .@y1, 1);
        getmapxy(.@map$, .@x2, .@y2, 0);
        .@distance = distance(.@x1, .@y1, .@x2, .@y2);
        .@chance = max(ArtisQuests_CatchPiou_Difficulcy,
                       20 + .@distance * 5 - .@agi/10 -
                       @ArtisQuests_CatchPiouTries);
        return rand(.@chance);
    }

    .@charid = getcharid(0);
    if (.LastPlayerTouched <= 0)
    {
        .LastPlayerTouched = .@charid;
        @ArtisQuests_CatchPiouTries = 0;
    }
    else if (.LastPlayerTouched != .@charid)
    {
        message strcharinfo(0), l("Looks like somebody else is looking for Chuck. I better leave them to try.");
        end;
    }

    .@q = getq(ArtisQuests_CatchPiou);
    if (.@q != 1)
    {
        mesn "Narrator";
        mesc(l("The hatchling looks at you with big, pleading eyes, and you don't have the heart to take it back to May."), 9);
        close;
    }

    .@tick = gettimetick(1);
    if (.@tick < .LastTimeTouched + min(4, ArtisQuests_CatchPiou_Difficulcy
                                        + @ArtisQuests_CatchPiouTries / 3))
    {
        mesq l("The hatchling spooked at your attempt to catch it, and zoomed out of sight.");
        .LastTimeTouched = .@tick;
        end;
    }

    .LastTimeTouched = .@tick;

    .@rnd = TryCatchPiou();
    if (!.@rnd)
    {
        npcstop;
        stopnpctimer;
        getmapxy(.@map$, .@x, .@y, 1);
        npcwalkto .@x, .@y;
        .@trader$ = "Salem#001-1";
        mesn "Narrator";
        mesc(l("Finally, you captured the speedy hatchling, but he's trying to squirm away! Hurry back to May before he escapes."), 9);
        setq LilitQuest_Hatchling, 1;
           getexp(1000, 500);
        set getvariableofnpc(.LastPiouHunter$, .@trader$), strcharinfo(0);
        set getvariableofnpc(.PiouEscapedMessage$, .@trader$), l("The little pipsqueak gave you the slip! You need to catch him again.");
        set getvariableofnpc(.LastPiouHunterID, .@trader$), .@charid;
        set getvariableofnpc(.PiouCaught, .@trader$), 1;
        donpcevent .@trader$ + "::OnPiouFlee";
        close2;
        disablenpc strnpcinfo(3);
        close;
    }
    else
    {
        setarray .RandomFailureMessages$[0], l("Nearly there!"), l("Like trying to catch a greased shrewboo..."), l("Aw, he got away again!"), l("Slippery little guy!");
        .@r = rand(getarraysize(.RandomFailureMessages$));
        message strcharinfo(0), .RandomFailureMessages$[.@r];
        .speed = max(140, 200 - 10 * (@ArtisQuests_CatchPiouTries +
                     ArtisQuests_CatchPiou_Difficulcy));
    }
    end;

OnHour00:
    .LastTimeTouched = 0;
    end;

OnTimer1000:
    dographmovestep;

OnInit:
    .distance = 5;
    .walkmask = WALK_WATER;

    initmovegraph "carpet middle",   38,  28,
                  "upper left",      34, 26,  32, 23,
                  "lower right",     41, 31,  44, 34,
                  "upper right",     42, 26,  44, 23,
                  "lower left",      35, 31,  32, 34,
                  "passage left",    32, 28,
                  "passage right",   44, 28,
                  ;

    setmovegraphcmd "carpet middle",  "upper left",    1, "wait 1; call ArtisFlyingPiouLogic",
                    "upper left", 	  "lower right",   1, "call ArtisFlyingPiouLogic",
                    "lower right",    "upper right",   2, "call ArtisFlyingPiouLogic",
                    "lower right", 	  "lower_left",    1, "call ArtisFlyingPiouLogic",
                    "upper right",    "lower left",    1, "call ArtisFlyingPiouLogic",
                    "lower left",     "table left",    1, "call ArtisFlyingPiouLogic",
                    "lower left",  	  "table right",   1, "call ArtisFlyingPiouLogic",
                    "passage left",   "carpet middle", 1, "wait 2; call ArtisFlyingPiouLogic",
                    "passage right",  "carpet middle", 1, "wait 2; call ArtisFlyingPiouLogic",
                    ;

    firstmove "speed 200", "market_start";
    initnpctimer;

    .LastPlayerTouched = -1;
    end;
}