summaryrefslogtreecommitdiff
path: root/npc/024-13/manager.txt
blob: d65897405e4f434ef1d99742d9c98e78562be571 (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
// TMW2: Moubootaur Legends scripts.
// Author:
//    Jesusalva
// Description:
//    Real Estate System

// ESTATE_ID → Instance ID of the Estate (required for NPCs, expire)
// ESTATE_RENTTIME → When the rent will expire
// ESTATE_MOBILIA_2 → Bitmask of mobilia currently purchased on Monster Collision (6) (Use on walls only)
// ESTATE_MOBILIA_4 → Bitmask of mobilia currently purchased on Air Collision (2)
// ESTATE_MOBILIA_8 → Bitmask of mobilia currently purchased on Water Collision (3)
// ESTATE_MOBILIA_32 → Bitmask of mobilia currently purchased on Yellow Collision (4)
// ESTATE_MOBILIA_64 → Bitmask of mobilia currently purchased on Normal Collision (1)
// ESTATE_MOBILIA_128 → Bitmask of mobilia currently purchased on Player Collision (5)

// REAL_ESTATE_CREDITS → Credits equivalent to GP the player have. Will be used first.

// The sign is the main controller
024-13,31,32,0	script	Apartment Manager	NPC_ELF,{
    if (ESTATE_RENTTIME < gettimetick(2))
        goto L_RentAvailable;

    mesn;
    mesq l("Your rent is valid for @@.", FuzzyTime(ESTATE_RENTTIME));
    mesc l("Apartment rents cannot be renewed until they expire. Furniture won't be lost.");
    close;

L_RentAvailable:
    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) {
            realestate_payment(.price);

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

            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("This is an apartment. You cannot renew until it expire, and cannot invite guests.");
            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);
    close;

OnInit:
    .sex = G_OTHER;
    .distance = 3;

    .@npcId = getnpcid(.name$);
    setunitdata(.@npcId, UDT_HEADTOP, BowlerHat);
    setunitdata(.@npcId, UDT_HEADMIDDLE, CreasedShirt);
    setunitdata(.@npcId, UDT_HEADBOTTOM, NPCEyes);
    setunitdata(.@npcId, UDT_WEAPON, LeatherTrousers);

    .price=5000; // Monthly rent price.
    .time=2592000; // Defaults to 30 days
    end;

}

// Door entrance
024-13,29,28,0	script	#RES_PPL	NPC_HIDDEN,0,0,{
    end;
OnTouch:
    if (ESTATE_RENTTIME < gettimetick(2))
        goto L_RentAvailable;

    // Warp you to your apartment if exists in memory already.
    // Build the instance otherwise.

    // Well, "checking if instance exist by mapname" is an illusion.
    // So we try to build and if we fail, we warp the player to the instance.
    .@ID=getcharid(0);
    @MAP_NAME$="ples@"+str(.@ID); // Max 4 chars for map name

    .@INSTID = instance_create("ples@a"+(.@ID), getcharid(3), IOT_CHAR);

    // Instance already exists - .@INSTID returns "-4"
    if (.@INSTID == -4) {
        warp @MAP_NAME$, 33, 33;
        end;
    }

    // Attach the map
    .@instanceMapName$ = instance_attachmap("024-14", .@INSTID, 0, @MAP_NAME$);

    // Record important stuff & load furniture
    ESTATE_ID=.@INSTID;
    addtimer(20, "Doorbell#RES_PPL::OnReload");
    addtimer(70, "NPCs#RES_PPL::OnReload");

    // It'll be self-destroyed eventually...
    instance_set_timeout(1000000, 1000000, .@INSTID);
    instance_init(.@INSTID);
    warp @MAP_NAME$, 33, 33;
    end;

L_RentAvailable:
    dispbottom l("You do not have booked an apartment here.");
    close;

OnInit:
    .distance=1;
    end;

}