summaryrefslogblamecommitdiff
path: root/npc/006-2-6/hatchling.txt
blob: df06409ebbe08f98341e2357d0a3f8a810ca3534 (plain) (tree)







































































































































                                                                                                                                                                         
// 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;
}