summaryrefslogtreecommitdiff
path: root/npc/functions/estate2.txt
blob: 99100f2f8c0894d7faae5d35ed690d8a884f0210 (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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
// TMW2: Moubootaur Legends scripts.
// Author:
//    Jesusalva
// Description:
//    Real Estate System
//    Secondary Script Helpers
//    WARNING: They affect directly the real estate global variables!
//////////////////////////////////////////////////////////////////////////////
///////////// Dialog Helpers
// "If you copy-paste the same line too often, make a function for it"

// Rent_Available Label
// Returns true regardless of player decision
// realestate_rent ( estate_id, price, <rent time> )
function	script	realestate_rent	{
    .id=getarg(0);
    .price=getarg(1);
    .time=getarg(2, 2592000); // Defaults to 30 days

    do
    {
        mesc l("This Real Estate is available for rent for only @@ GP!", format_number(.price));
        .@gp=REAL_ESTATE_CREDITS+Zeny;
        mesc l("You currently have: @@ GP and mobiliary credits", format_number(.@gp));
        next;
        select
            rif(.@gp > .price, l("Rent it! Make it mine!")),
            l("Information"),
            l("Don't rent it");

        // You want to rent
        if (@menu == 1) {
            if ($ESTATE_RENTTIME[.id] > gettimetick(2)) {
                mesc l("Somebody already rented it before you!");
                close;
            }
            REAL_ESTATE_CREDITS=REAL_ESTATE_CREDITS-.price;
            if (REAL_ESTATE_CREDITS < 0) {
                Zeny+=REAL_ESTATE_CREDITS;
                REAL_ESTATE_CREDITS=0;
            }

            // Payment done, you can now acquire the house for a month
            $ESTATE_RENTTIME[.id]=gettimetick(2)+.time;

            // If you're not the previous owner
            // Remove previous owner furniture and reset room password
            if ($ESTATE_OWNER[.id] != getcharid(3)) {
                /*
                $ESTATE_MOBILIA_2[.id]=0;
                $ESTATE_MOBILIA_4[.id]=0;
                $ESTATE_MOBILIA_8[.id]=0;
                $ESTATE_MOBILIA_32[.id]=0;
                $ESTATE_MOBILIA_64[.id]=0;
                $ESTATE_MOBILIA_128[.id]=0;
                */
                $ESTATE_PASSWORD$[.id]="";
                $ESTATE_DOORBELL[.id]=false;
            }

            // Register your info so you can manage it
            $ESTATE_OWNER[.id]=getcharid(3);
            $ESTATE_OWNERNAME$[.id]=strcharinfo(0);

            mesc l("Rent successful for 30 days!");
        } else if (@menu == 2) {
            mesc l("You can rent this house to make it yours.") + " " + l("The rent lasts 30 days.");
            mesc l("Then you'll be able to buy furniture and utility.");
            mesc l("The door is password-protected, so your friends can enter but strangers stay outside.");
            next;
            mesc l("Both rent and furniture are bought using money, however, there are mobiliary credits.");
            mesc l("Mobiliary Credits is a special currency which can only be used on real estate.");
            mesc l("It's obtained with ADMINS or by selling furniture. It is sumed to money and used first.");
            next;
        }
    } while (@menu == 2);
    return true;
}





// L_Manage Label
// Returns true regardless of player decision
// realestate_manage ( estate_id, price, <rent time> )
function	script	realestate_manage	{
    .id=getarg(0);
    .price=getarg(1);
    .time=getarg(2, 2592000); // Defaults to 30 days

    do
    {
        mesc l("@@'s Estate", strcharinfo(0));
        mesc ".:: "+ l("Managment Menu") + " ::.";

        .@gp=REAL_ESTATE_CREDITS+Zeny;
        mesc l("Rent time available: @@", FuzzyTime($ESTATE_RENTTIME[.id]));
        mesc l("Total Credits and GP: @@", format_number(.@gp));
        mes "";
        mesc l("Rent Renew Price: @@ GP", format_number(.price));
        mesc l("Room password: @@", $ESTATE_PASSWORD$[.id]);
        if ($ESTATE_DOORBELL[.id])
            mesc l("Doorbell is disabled"), 1;

        next;
        select
            l("Leave"),
            l("Enable/disable doorbell"),
            l("Set room password"),
            rif(.@gp >= .price && $ESTATE_RENTTIME[.id] < gettimetick(2)+.time, l("Renew Rent")),
            rif($@GM_OVERRIDE, l("Destroy all mobilia")),
            rif($@GM_OVERRIDE, l("Expire rent time"));

        switch (@menu) {
            case 1:
                break;
            case 2:
                $ESTATE_DOORBELL[.id]=!$ESTATE_DOORBELL[.id];
                break;
            case 3:
                mesc l("(Leave the password blank to disable)");
                mesc l("Current Room password: @@", $ESTATE_PASSWORD$[.id]);
                mesc l("Input new password: ");
                input .@password$;
                mesc l("Repeat new password: ");
                input .@passwordc$;
                if (.@password$ == .@passwordc$) {
                    $ESTATE_PASSWORD$[.id]=.@password$;
                    mesc l("Password changed with success!"), 3;
                } else {
                    mesc l("The passwords doesn't match."), 1;
                }
                break;
            case 4:
                // The check is performed before showing the menu option
                // I guess it could be hacked, but I'll probably see negative GP...
                REAL_ESTATE_CREDITS=REAL_ESTATE_CREDITS-.price;
                if (REAL_ESTATE_CREDITS < 0) {
                    Zeny+=REAL_ESTATE_CREDITS;
                    REAL_ESTATE_CREDITS=0;
                }

                // Payment done, you can now acquire the house for a month
                // If you lost the rent on the meanwhile, it'll renew
                // If you lost the rent and somebody else rented it, you lose the GP
                $ESTATE_RENTTIME[.id]+=.time;
                break;
            case 5:
                mesc l("Are you sure? This cannot be undone!"), 1;
                next;
                if (validatepin()) {
                    $ESTATE_MOBILIA_2[.id]=0;
                    $ESTATE_MOBILIA_4[.id]=0;
                    $ESTATE_MOBILIA_8[.id]=0;
                    $ESTATE_MOBILIA_32[.id]=0;
                    $ESTATE_MOBILIA_64[.id]=0;
                    $ESTATE_MOBILIA_128[.id]=0;
                    $ESTATE_PASSWORD$[.id]="";
                    $ESTATE_DOORBELL[.id]=false;
                }
            case 6:
                mesc l("Are you sure? This cannot be undone!"), 1;
                next;
                if (validatepin()) {
                    $ESTATE_RENTTIME[.id]=gettimetick(2);
                }
        }
    } while (@menu != 1);
    return true;
}


// Piano Mobilia
// realestate_piano ( {mapname} )
function	script	realestate_piano	{
    .@loc$=getarg(0, getmap());
    mesc l("Do you want to play a song?");
    mesc l("This is not saved.");
    select
        l("Nothing"),
        l("Default"),
        l("Indoors 1 (Peace)"),
        l("Indoors 2 (Dimonds)"),
        l("TMW Adventure"),
        l("Sailing Away!"),
        l("Magick Real"),
        l("The Forest"),
        l("Dragons and Toast"),
        l("Unforgiving Lands"),
        l("Arabesque (Action)"),
        l("No Chains (Tulimshar)"),
        l("School of Quirks (Candor)"),
        l("Cake Town (Hurnscald)"),
        l("Steam (LoF Village)"),
        l("Woodland Fantasy"),
        l("Birds in the Sunrise");

    mes "";
    .@m$="";
    switch (@menu) {
        case 1:
            return; break;
        case 2:
            .@m$="8bit_the_hero.ogg"; break;
        case 3:
            .@m$="peace.ogg"; break;
        case 4:
            .@m$="peace2.ogg"; break;
        case 5:
            .@m$="tmw_adventure.ogg"; break;
        case 6:
            .@m$="sail_away.ogg"; break;
        case 7:
            .@m$="magick_real.ogg"; break;
        case 8:
            .@m$="dariunas_forest.ogg"; break;
        case 9:
            .@m$="dragon_and_toast.ogg"; break;
        case 10:
            .@m$="Unforgiving_Lands.ogg"; break;
        case 11:
            .@m$="Arabesque.ogg"; break;
        case 12:
            .@m$="mvrasseli_nochains.ogg"; break;
        case 13:
            .@m$="school_of_quirks.ogg"; break;
        case 14:
            .@m$="caketown.ogg"; break;
        case 15:
            .@m$="steam.ogg"; break;
        case 16:
            .@m$="woodland_fantasy.ogg"; break;
        case 17:
            .@m$="tws_birds_in_the_sunrise.ogg"; break;

    }
    changemusic .@loc$, .@m$;
    return;
}



// Cauldron Mobilia
// realestate_cauldron (  )
function	script	realestate_cauldron	{
    select
        l("Alchemy"),
        l("Crafting");
    mes "";
    if (@menu == 1) {
        do {
            mesc l("What will you brew today?");
            if (AlchemySystem(CRAFT_PLAYER))
                mesc l("Success!"), 3;
            else
                mesc l("That didn't work!"), 1;
            next;
            mesc l("Try again?");
        } while (askyesno() == ASK_YES);
    }
    else if (@menu == 2) {
        do {
            mesc l("What will you craft today?");
            if (SmithSystem(CRAFT_PLAYER))
                mesc l("Success!"), 3;
            else
                mesc l("That didn't work!"), 1;
            next;
            mesc l("Try again?");
        } while (askyesno() == ASK_YES);
    }
    return;
}

////////////////////////////////////////////////////////////////////////////
// TODO: NPCs toogle on/off controller?

////////////////////////////////////////////////////////////////////////////
012-8,21,23,0	script	Wardrobe#RES_0128	NPC_NO_SPRITE,{
    openstorage;
    end;

OnInit:
    .distance=3;
    end;
}

017-7,21,23,0	duplicate(Wardrobe#RES_0128)	Wardrobe#RES_0177	NPC_NO_SPRITE
017-8,21,23,0	duplicate(Wardrobe#RES_0128)	Wardrobe#RES_0178	NPC_NO_SPRITE
009-6,21,23,0	duplicate(Wardrobe#RES_0128)	Wardrobe#RES_0096	NPC_NO_SPRITE
009-7,21,23,0	duplicate(Wardrobe#RES_0128)	Wardrobe#RES_0097	NPC_NO_SPRITE


////////////////////////////////////////////////////////////////////////////
012-8,29,24,0	script	Cauldron#RES_0128	NPC_NO_SPRITE,{
    realestate_cauldron();
    close;

OnInit:
    .distance=3;
    end;
}

017-7,29,24,0	duplicate(Cauldron#RES_0128)	Cauldron#RES_0177	NPC_NO_SPRITE
017-8,29,24,0	duplicate(Cauldron#RES_0128)	Cauldron#RES_0178	NPC_NO_SPRITE
009-6,29,24,0	duplicate(Cauldron#RES_0128)	Stovetop#RES_0096	NPC_NO_SPRITE
009-7,29,24,0	duplicate(Cauldron#RES_0128)	Stovetop#RES_0097	NPC_NO_SPRITE


////////////////////////////////////////////////////////////////////////////
012-8,34,25,0	script	Piano#RES_0128	NPC_NO_SPRITE,{
    realestate_piano();
    close;

OnInit:
    .distance=3;
    end;
}

017-7,34,25,0	duplicate(Piano#RES_0128)	Piano#RES_0177	NPC_NO_SPRITE
017-8,34,25,0	duplicate(Piano#RES_0128)	Piano#RES_0178	NPC_NO_SPRITE
009-6,34,25,0	duplicate(Piano#RES_0128)	Piano#RES_0096	NPC_NO_SPRITE
009-7,34,25,0	duplicate(Piano#RES_0128)	Piano#RES_0097	NPC_NO_SPRITE