summaryrefslogtreecommitdiff
path: root/npc/001-3-0/mundane.txt
blob: 58a47cb2093f3fe3e58a8de33e85682af141c103 (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// Evol Scripts
// Author:
//    Jesusalva
// Description:
//    Mundane (anagram of Unnamed) is Mona's father
//    He likes to smoke cigarettes while looking for the strange sounds.
//    He is an old bowman of the Legion. He was married but it is not clear
//    what happened to his wife.
// Lore Problems:
//    If he is missing for a week already, how is he eating anyway?
//    Also, is he afraid of blubs/rattos or of Green Slimes?

// Note: Jesusalva is not someone to care a lot with code styling, and he uses
// a convention of his own, gumi will need to cleanse the code before it gets
// compliant with Evol Coding Style Guidelines.
// Note 2: Logout is not handled. Making logout at an instanced map may randomly
// warp you back to Drasil Island (000-1) or something like that. I don't know.
// This behavior remains to be checked.

001-3-0,96,66,0	script	Mundane	NPC_MUNDANE,{

    function quest_completed
    {
    speech(0x0,
        l("No matter how many times I come here, I can't find the reason for the strange sounds..."),
        l("It is either a huge monster, some cultists, or someone throwing strange stuff into sewers."));
    close;
    }

    function quest_inprogress
    {
    speech(0x0,
        l("We need to get out of here soon. I'm scared of the Slimes!"));
    close;
    }

    function rescue_mundane
    {
    speech(S_LAST_NEXT,
        l("Scary... I am afraid of all these Slimes, Rattos and Maggots... And worse, I am lost..."),
        l("I was an archer of the Legion and shouldn't be scared of a few maggots, but everyone has fears, right?!"),
        l("My daughter is probably worried about me. Could you perhaps lead me out of here?"));

        switch (select(l("Yes, follow me!"), l("Not now. You see, I am also afraid of Slimes and Rattos!")))
        {
            case 1:
                mes "";
                break;
            case 2:
                speech(S_FIRST_BLANK_LINE,
                    l("That's too bad... Although I think you're lying."),
                    l("If so, please take some courage and help me!"));
                close;
                break;
        }
        .@ID=getcharid(0);
        .@MAP_NAME$="mona@"+str(.@ID);
        @MUNDANE_INSTID = instance_create("001-3-0@a"+(.@ID), getcharid(3), IOT_CHAR);

        // XXX - Important Note - XXX
        // We currently have only FOUR chars to name the map. "001-3-0" or "mundane" have 7 chars, so that cannot be used.
        // Thankfully, "mona" have 4 chars, so it's the name.
        //
        // Rationale: We have only 11 chars available, but 7 are reserved. So, longest name would be "abcd" + "@" + getcharid(0)
        // Some test reported that (apparently) we have 15 whitespaces at map name start, not sure why.
        .@instanceMapName$ = instance_attachmap("001-3-0", @MUNDANE_INSTID, 0, .@MAP_NAME$);

        // This can be a bug, but most likely is because instance already exists.
        // I don't know what would happen if we continue, so let's "penalize" the player
        if (.@instanceMapName$ == "") {
            speech(0x0,
                l("Wait... You are that @@ from earlier, aren't you?", strcharinfo(0)),
                l("If my memory serves me right, you were just defeated. Why don't you go out to buy better equipment?"));
            close;
        }

        // You have 5 minutes to complete the quest. This does not results in failure by itself, getq2 does that
        instance_set_timeout(300, 300, @MUNDANE_INSTID);
        instance_init(@MUNDANE_INSTID);
        dispbottom(l("Mona's father is right behind you. You have five minutes to bring him out of sewers!"));

        // Note: Difficulty is based on your level
        .@BLVLBOOST=BaseLevel/10;
        areamonster(.@MAP_NAME$, 119, 51, 162, 85, strmobinfo(1, Slime), Slime, 3+.@BLVLBOOST);
        areamonster(.@MAP_NAME$, 190, 65, 193, 68, strmobinfo(1, Ratto), Ratto, 5);
        areamonster(.@MAP_NAME$, 90, 67, 92, 72, strmobinfo(1, CaveMaggot), CaveMaggot, 3+.@BLVLBOOST);
        areamonster(.@MAP_NAME$, 99, 106, 102, 111, strmobinfo(1, Slime), Slime, 3+.@BLVLBOOST);
        areamonster(.@MAP_NAME$, 115, 93, 115, 75, strmobinfo(1, Slime), Slime, 3+.@BLVLBOOST);
        areamonster(.@MAP_NAME$, 120, 85, 7, 2, strmobinfo(1, LittleSlime), LittleSlime, 7+.@BLVLBOOST);
        areamonster(.@MAP_NAME$, 114, 65, 121, 68, strmobinfo(1, CaveMaggot), CaveMaggot, 5+.@BLVLBOOST);
        areamonster(.@MAP_NAME$, 137, 76, 130, 87, strmobinfo(1, Spider), Spider, 4+.@BLVLBOOST);
        areamonster(.@MAP_NAME$, 98, 92, 101, 94, strmobinfo(1, Slime), Slime, 3+.@BLVLBOOST);

        // Important temporary variables and move you accordingly
        @MUNDANE_OLDX=.x;
        @MUNDANE_OLDY=.y;
        warp(.@MAP_NAME$, .x, .y);
        // Move NPC as well
        unitwarp(getnpcid(instance_npcname(.name$, @MUNDANE_INSTID)), .@MAP_NAME$, .x, .y);

        setq ArtisQuests_MonaDad, 2;
        addtimer(150, instance_npcname(.name$, @MUNDANE_INSTID)+"::OnMove");
        updateSpotlight(true);
        close;

    }

    .@q=getq(ArtisQuests_MonaDad);
    if (.@q >= 3) quest_completed();
    if (.@q == 2) quest_inprogress();
    if (.@q == 1) rescue_mundane();
    // Impossible situation, but let's not trust this. You must talk to Mona first!
    if (.@q == 0) quest_completed();

    hello;
    end;

// This functions serves two major purposes:
//  1- Move Mundane accordingly
//  2- Be able to determine if you brought Mundane to exit or cheat (warp, etc.)
// NOTE: Using instance_npcname(.name$) can be unreliable at times.
//  It should work with addtimer(), but if it breaks, move @MUNDANE_INSTID to
//  the @ varspace, and use instance_npcname(.name$, @MUNDANE_INSTID)
//  That'll fix any problem when playtesting.
OnMove:
    getmapxy(.@m$, .@x, .@y, 0);
    // You left the map, we don't need to move NPC anymore
    if (!(.@m$ ~= "mona@*") && (.@m$ != "001-3-0")) {
        disablenpc(instance_npcname(.name$, @MUNDANE_INSTID));
        // This check shouldn't be needed but better safe than sorry
        if (.@m$ == "001-1")
            dispbottom l("Mundane ran straight home. He must be missing his daughter.");
        else
            dispbottom l("Mundane ran away, he did not trust the path you chose.");
        end;
    }
    // We actually won't move the NPC to your position, but to where you were last.
    // The NPC should not walk right in you because I thought it looks weird ingame.
    if (.@x == @MUNDANE_OLDX && .@y == @MUNDANE_OLDY) {
        addtimer(150, instance_npcname(.name$, @MUNDANE_INSTID)+"::OnMove");
        end;
    }

    // movenpc() will cause NPC to "jump" to player position.
    // npcwalkto(x, y) will make it walk to your position.
    npcwalkto @MUNDANE_OLDX, @MUNDANE_OLDY;

    // We now update the misleading @MUNDANE_OLD* variable with your current
    // position.
    @MUNDANE_OLDX=.@x;
    @MUNDANE_OLDY=.@y;
    // We must handle this every 150ms or so, which is player walk delay.
    // When you leave the map this timer will die.
    addtimer(150, instance_npcname(.name$, @MUNDANE_INSTID)+"::OnMove");
    end;

OnInit:
    .distance = 3;
    .speed = 140;

// Move Mundane every Sunday, Wednesday, and Friday
// to be less repetitive, and save also where it is
OnSun0000:
OnWed0000:
OnFri0000:
    if (.begin)
        delcells "MundaneProtection";

    // Micksha may tweak this.
    setarray .@valid_x, 96, 132, 150, 49;
    setarray .@valid_y, 66,  86, 118, 47;
    .@index=rand(0,getarraysize(.@valid_x)-1);
    movenpc .name$, .@valid_x[.@index], .@valid_y[.@index];

    // Create a 3x3 monster collision block over Mundane
    setcells .map$, .x-3, .y-3, .x+3, .y+3, 6, "MundaneProtection";
    .begin=true;
    end;

OnInstanceInit:
    .speed = 140; // Double-sure
    end;

}

function	script	MundaneLogout	{
    if (getq(ArtisQuests_MonaDad) != 2) return;
    setq ArtisQuests_MonaDad, 1;
    return;
}

function	script	MundaneDeath	{
    if (getq(ArtisQuests_MonaDad) != 2) return;
    setq ArtisQuests_MonaDad, 1;
    dispbottom l("What a pity! You've died.");

    // We must disable Mona's Dad NPC sprite if you are still on the map
    // This will cause the NPC to "vanish", player is left to guess that he ran
    // back to where he originally was.
    // (ie. The NPC won't be fine without you if we have code to handle that).
    // NOTE: Maybe we could send the NPC running back to his original position?
    // For future thought and testing by anyone interested.
    if (strpos(getmap(), "mona@") >= 0) {
        disablenpc(instance_npcname(.name$, @MUNDANE_INSTID));
    }
    return;
}