summaryrefslogtreecommitdiff
path: root/npc/functions/estate.txt
blob: b9dae84b6031c4af345803d696233192176eb131 (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
// TMW2: Moubootaur Legends scripts.
// Author:
//    Jesusalva
// Description:
//    Real Estate System
//    Script Helpers
//    For all your real estate purposes

// This function reduces payment accordingly
// realestate_payment ( amount )
function	script	realestate_payment	{
    REAL_ESTATE_CREDITS=REAL_ESTATE_CREDITS-getarg(0);
    if (REAL_ESTATE_CREDITS < 0) {
        Zeny+=REAL_ESTATE_CREDITS;
        REAL_ESTATE_CREDITS=0;
    }
    return;
}

// Generate unique name for setcells
// realestate_cellname ( estate_id, object_id )
function	script	realestate_cellname	{
    return "RESObj_"+getarg(0)+"_"+getarg(1);
}

// Generate sell price for furniture based on original price and estate ID
// realestate_sellprice ( estate_id, price )
function	script	realestate_sellprice	{
    .@timeleft=$ESTATE_RENTTIME[getarg(0)]-gettimetick(2); // Number of seconds
    .@daysleft=.@timeleft/86400; // Number of days left of rent
    .@weeksleft=.@timeleft/604800; // Number of weeks left of rent

    //debugmes "Your contract is valid for %d weeks more - %d days", .@weeksleft, .@daysleft;
    //debugmes "The divisor is %d", max(1, 8-.@weeksleft);

    return (getarg(1)/max(1, 8-.@weeksleft)) - max(0, 60-.@daysleft);
}