summaryrefslogtreecommitdiff
path: root/npc/001-1/flyingpiou.txt
blob: ea48f4dcc6fefba9c5136e472fe7c730af13ff5e (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Evol scripts.
// Author:
//    Travolta
// Description:
//    Pious flying around town
// 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;
}

001-1,53,117,0	script	#FlyingPiou1	NPC_FLYING_PIOU,{

    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("Hm, it seems another player is trying to catch the piou, I shouldn't interfere.");
        end;
    }

    .@q = getq(ArtisQuests_CatchPiou);
    if (.@q != 1)
    {
        mesn "Narrator";
        mesc(l("You scare the piou, but let it go."), 9);
        close;
    }

    .@tick = gettimetick(1);
    if (.@tick < .LastTimeTouched + min(4, ArtisQuests_CatchPiou_Difficulcy
                                        + @ArtisQuests_CatchPiouTries / 3))
    {
        message strcharinfo(0), l("Dang, I scared it! More patience, @@, more patience.", strcharinfo(0));
        .LastTimeTouched = .@tick;
        specialeffect(33, SELF);
        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("You caught the piou, but it's trying to escape from you. You'd better hurry back to Salem."), 9);
        set getvariableofnpc(.LastPiouHunter$, .@trader$), strcharinfo(0);
        set getvariableofnpc(.PiouEscapedMessage$, .@trader$), l("Oh no, the piou escaped!");
        set getvariableofnpc(.LastPiouHunterID, .@trader$), .@charid;
        set getvariableofnpc(.PiouCaught, .@trader$), 1;
        donpcevent .@trader$ + "::OnPiouFlee";
        specialeffect(26, SELF);
        close2;
        disablenpc strnpcinfo(3);
        close;
    }
    else
    {
        setarray .RandomFailureMessages$[0], l("So close!"), l("It escaped!"), l("Almost got it!"), l("Oh, the little...");
        .@r = rand(getarraysize(.RandomFailureMessages$));
        message strcharinfo(0), .RandomFailureMessages$[.@r];
        .speed = max(140, 200 - 10 * (@ArtisQuests_CatchPiouTries +
                     ArtisQuests_CatchPiou_Difficulcy));
        specialeffect(33, SELF);
    }
    end;

OnHour00:
    .LastTimeTouched = 0;
    end;

OnTimer1000:
    dographmovestep;

OnInit:
    .distance = 5;
    .walkmask = WALK_WATER;
    // .debug = 1;

    initmovegraph "market_start",    53,  117,
                  "fountain",        79,  75,  102, 91,
                  "river_bank_1",    107, 94,  117, 102,
                  "river_bank_2",    117, 110,
                  "chelios_right",   100, 112, 113, 118,
                  "chelios_left",    80,  95,  93,  111,
                  "market_right",    74,  114, 83,  121,
                  "market_center",   50,  113, 66,  121,
                  "market_left",     36,  120, 42,  128,
                  "batiment_inside", 48,  138, 65,  106,
                  "batiment_behind", 33,  90,  41,  103,
                  "library_front",   42,  82,  63,  90,
                  "taree_yard",      69,  82,
                  "taree_behind",    61,  62,  76,  71,
                  "townhall_behind", 73,  40,  93,  55,
                  "townhall_right",  99,  55,  106, 60,
                  "inn_behind",      107, 63,  123, 76
                  ;

    setmovegraphcmd "fountain",       "river_bank_1",   1, "call ArtisFlyingPiouLogic",
                    "river_bank_1",   "river_bank_2",   1, "call ArtisFlyingPiouLogic",
                    "river_bank_2",   "chelios_right",  2, "call ArtisFlyingPiouLogic",
                    "chelios_right",  "chelios_left",   1, "call ArtisFlyingPiouLogic",
                    "chelios_left",   "fountain",       1, "wait 1; call ArtisFlyingPiouLogic",
                    "chelios_left",   "market_right",   1, "call ArtisFlyingPiouLogic",
                    "chelios_right",  "market_right",   1, "call ArtisFlyingPiouLogic",
                    "market_right",   "market_center",  1, "call ArtisFlyingPiouLogic",
                    "market_center",  "batiment_inside",1, "call ArtisFlyingPiouLogic",
                    "batiment_inside","library_front",  1, "call ArtisFlyingPiouLogic",
                    "library_front",  "taree_yard",     1, "call ArtisFlyingPiouLogic",
                    "library_front",  "taree_behind",   1, "call ArtisFlyingPiouLogic",
                    "library_front",  "batiment_behind",1, "call ArtisFlyingPiouLogic",
                    "batiment_behind","market_left",    1, "wait 3; call ArtisFlyingPiouLogic",
                    "market_left",    "market_center",  1, "call ArtisFlyingPiouLogic",
                    "taree_yard",     "fountain",       1, "call ArtisFlyingPiouLogic",
                    "taree_behind",   "townhall_behind",1, "call ArtisFlyingPiouLogic",
                    "townhall_behind","townhall_right", 1, "call ArtisFlyingPiouLogic",
                    "townhall_right", "inn_behind",     1, "call ArtisFlyingPiouLogic",
                    "inn_behind",     "fountain",       1, "wait 2; call ArtisFlyingPiouLogic",
                    "inn_behind",     "river_bank_1",   1, "call ArtisFlyingPiouLogic",
                    "market_start",   "batiment_inside",1, "call ArtisFlyingPiouLogic"
                    ;

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

    .LastPlayerTouched = -1;
    end;
}