summaryrefslogtreecommitdiff
path: root/npc/009-1/estate_2.txt
blob: 1dc723d1e115e4b7bb64d9bbf198b2cd2e176242 (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
// TMW2: Moubootaur Legends scripts.
// Author:
//    Jesusalva
// Description:
//    Real Estate System

// ID: 5
// $ESTATE_OWNER[.id] → Account ID owner of the Real Estate
// $ESTATE_OWNERNAME$[.id] → Human readable name of Real Estate owner
// $ESTATE_RENTTIME[.id] → When the rent will expire
// $ESTATE_MOBILIA_2[.id] → Bitmask of mobilia currently purchased on Monster Collision (6) (Use on walls only)
// $ESTATE_MOBILIA_4[.id] → Bitmask of mobilia currently purchased on Air Collision (2)
// $ESTATE_MOBILIA_8[.id] → Bitmask of mobilia currently purchased on Water Collision (3)
// $ESTATE_MOBILIA_32[.id] → Bitmask of mobilia currently purchased on Yellow Collision (4)
// $ESTATE_MOBILIA_64[.id] → Bitmask of mobilia currently purchased on Normal Collision (1)
// $ESTATE_MOBILIA_128[.id] → Bitmask of mobilia currently purchased on Player Collision (5)
// $ESTATE_PASSWORD$[.id] → Password to enter the estate. If it is "", then no password required
// Note: GMs and Administrators can always use super password "mouboo" to enter a locked estate
// $ESTATE_DOORBELL[.id] → If doorbell is disabled (enabled by default)

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

// The sign is the main controller
009-1,108,46,0	script	Sign#RES_0097	NPC_SWORDS_SIGN,{
    if ($ESTATE_RENTTIME[.id] < gettimetick(2))
        goto L_RentAvailable;

    if ($ESTATE_OWNER[.id] == getcharid(3))
        goto L_Manage;

    if (is_admin() && $@GM_OVERRIDE)
        goto L_Manage;

    mesc l("This estate currently belongs to @@.", $ESTATE_OWNERNAME$[.id]);
    mesc l("Press the doorbell?");
    next;
    if (askyesno() == ASK_YES)
        doevent "Doorbell#RES_0097::OnDoorbell";
    close;

L_RentAvailable:
    realestate_rent(.id, .price);
    close;

L_Manage:
    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:
            close;
            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);
            }
    }
    goto L_Manage;
    close;

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

    // Estate Settings
    .id=5; // Estate ID
    .price=40000; // Monthly rent price
    .time=60*60*24*30; // How long last default rent time. In future could consider month.
    end;

}

// Door entrance
009-1,109,45,0	script	#RES_0097	NPC_HIDDEN,0,0,{
    end;
OnTouch:
    if ($ESTATE_RENTTIME[.id] < gettimetick(2))
        goto L_RentAvailable;

    if ($ESTATE_OWNER[.id] == getcharid(3) || $ESTATE_PASSWORD$[.id] == "")
        goto L_Warp;

    mesc l("The door is locked");
    next;
    mesc l("However, it can be unlocked if you know the password:");
    if (is_gm()) mesc l("You can use super password \"mouboo\" to unlock the door."), 1;
    input .@password$;
    // GMs can use super password "mouboo"
    if (.@password$ == $ESTATE_PASSWORD$[.id] || (is_gm() && .@password$ == "mouboo"))
        goto L_Warp;
    close;

L_Warp:
    warp "009-7", 33, 33;
    closeclientdialog;
    close;

L_RentAvailable:
    dispbottom l("This estate is available for rent, talk to the sign to rent it.");
    close;

OnInit:
    // Estate Settings
    .id=5; // Estate ID
    end;

}