// TMW2: Moubootaur Legends scripts. // Author: // Jesusalva // Description: // Real Estate System // Doorbell allows you to purchase mobilia, besides loading it when server starts // Each layer can have 32 different furniture pieces because bitmask limit. // This file is custom to every room // ID: 1 // $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 Player Collision (5) // $ESTATE_MOBILIA_128[.id] → Bitmask of mobilia currently purchased on Normal Collision (1) // $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 012-8,32,34,0 script Doorbell#RES_0128 NPC_NO_SPRITE,{ // Name, Layer, Price, ID, x1, y1, x2, y2, function create_object { array_push(.name$, getarg(0)); array_push(.layer, getarg(1)); array_push(.price, getarg(2)); array_push(.objid, getarg(3)); array_push(.x1, getarg(4)); array_push(.y1, getarg(5)); array_push(.x2, getarg(6)); array_push(.y2, getarg(7)); return; } if ($ESTATE_OWNER[.id] == getcharid(3)) goto L_Manage; mesc l("This estate currently belongs to @@.", $ESTATE_OWNERNAME$[.id]); close; // If someone press the doorbell from outside and doorbell is enabled OnDoorbell: if (!$ESTATE_DOORBELL[.id]) end; if (.dpost < gettimetick(2)) { npctalk ("@@ is pressing the doorbell.", strcharinfo(0)); } .dpost=gettimetick(2)+.delay; end; // Managment Menu 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("Room password: @@", $ESTATE_PASSWORD$[.id]); if ($ESTATE_DOORBELL[.id]) mesc l("Doorbell is disabled"), 1; next; select l("Leave"), l("Enable/disable doorbell"), l("Manage Furniture"), l("Set room password"); switch (@menu) { case 1: close; break; case 2: $ESTATE_DOORBELL[.id]=!$ESTATE_DOORBELL[.id]; break; case 3: goto L_Furniture; break; case 4: 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; } goto L_Manage; L_Furniture: mesc l("@@'s Estate", strcharinfo(0)); mesc ".:: "+ l("Furniture Menu") + " ::."; .@gp=REAL_ESTATE_CREDITS+Zeny; mesc l("Total Credits and GP: @@", format_number(.@gp)); next; select l("Finish"), l("Manage beds"), l("Manage shelves"), l("Manage luxury furniture"), l("Manage Desks and Chairs"), // Note: Put chairs in mobilia32 l("Manage Paintings"); mes ""; switch (@menu) { case 1: goto L_Manage; break; case 2: mesc l("Beds"), 3; @re_col=1; // Collision layer to look up .@gp=REAL_ESTATE_CREDITS+Zeny; // How much you have //@valid_ids=0; // Array of valid entries deletearray @valid_ids; for (.@i=0; .@i < getarraysize(.layer); .@i++) { //debugmes "Found object ID %d named %s on layer %s coords (%d,%d) - Looking for layer %d", .@i, .name$[.@i], .layer[.@i], .x1[.@i], .y1[.@i], @re_col; if (.layer[.@i] == @re_col) { // We have a valid object // So we can populate a second array? // Allow to buy/sell and also setcells with params // Maybe an htable would work better (name$, .@id) array_push(@valid_ids, .@i); //debugmes "Pushing"; } } debugmes "Found %d valid objects", getarraysize(@valid_ids); // Add a function here @menuentries$=""; for (.@j=0; .@j < getarraysize(@valid_ids); .@j++) { .@i=@valid_ids[.@j]; if ($ESTATE_MOBILIA_2[.id] & .objid[.@i]) @menuentries$+=("Sell ")+.name$[.@i]+l(" for ") + format_number( realestate_sellprice(.id,.price[.@i]) ) +":"; else @menuentries$+=("Purchase ")+.name$[.@i]+(" for ") + format_number( .price[.@i] )+":"; } select (@menuentries$); mes ""; // We have then that (@menu-1) is the ID to toggle // in other words, .@id handles everything now .@id=@valid_ids[@menu-1]; if (realestate_hasmobilia(.id, .layer[.@id], .objid[.@id])) { // If you have the mobilia, you're selling it for Mobiliary Credits .@price=realestate_sellprice(.id,.price[.@i]); realestate_togglemobilia(.id, .layer[.@id], .objid[.@id]); REAL_ESTATE_CREDITS+=.@price; delcells realestate_cellname(.id, .@id); mesc l("Sale successful!"); next; } else { // Else, you're buying it .@price=.price[.@id]; if (.@gp > .@price) { realestate_payment(.@price); realestate_togglemobilia(.id, .layer[.@id], .objid[.@id]); setcells .mapa$, .x1[.@id], .y1[.@id], .x2[.@id], .y2[.@id], .layer[.@id], realestate_cellname(.id, .@id); mesc l("Purchase successful!"); next; } else { mesc l("Not enough funds!"); next; } } // Repeat the loop break; case 3: goto L_Furniture; break; case 4: break; } goto L_Furniture; L_FindLoop: OnInit: .sex = G_OTHER; .distance = 3; // Estate Settings .id=1; // Estate ID .delay=15; // Forced wait between rings .dpost=0; // Last doorbell ring .mapa$="012-8"; // Arrays // We go element by element on the array building the menu .name$=""; .layer=0; .price=0; .objid=0; .x1=0; .y1=0; .x2=0; .y2=0; // Furniture Settings // Name, Collision Layer, Price, ID, x1, y1, x2, y2 create_object("Placeholder" ,99,999999,99999, 99, 99, 99, 99); create_object("Bed 01" , 1, 5000, 1, 24, 24, 25, 27); create_object("Bed 02" , 1, 5000, 2, 26, 24, 27, 27); create_object("Bed 03" , 1, 5000, 4, 28, 24, 29, 27); create_object("Bed 04" , 1, 5000, 8, 30, 24, 31, 27); create_object("Bed 05" , 1, 5000, 16, 24, 29, 25, 32); create_object("Bed 06" , 1, 5000, 32, 26, 29, 27, 32); create_object("Bed 07" , 1, 5000, 64, 28, 29, 29, 32); create_object("Bed 08" , 1, 5000, 128, 30, 29, 31, 32); create_object("Wardrobe" , 5, 7000, 1, 21, 23, 22, 23); create_object("Cauldron" , 5, 5000, 2, 28, 24, 29, 24); create_object("Shelf 01" , 5, 2000, 4, 25, 23, 25, 23); create_object("Shelf 02" , 5, 2000, 8, 26, 23, 26, 23); create_object("Shelf 03" , 5, 2000, 16, 27, 23, 27, 23); create_object("Shelf 04" , 5, 2000, 32, 30, 23, 30, 23); create_object("Shelf 05" , 5, 2000, 64, 31, 23, 31, 23); create_object("Shelf 06" , 5, 2000, 128, 32, 23, 32, 23); create_object("Shelf 07" , 5, 2000, 256, 33, 23, 33, 23); create_object("Shelf 08" , 5, 2000, 512, 34, 23, 34, 23); create_object("Shelf 09" , 5, 2000, 1024, 35, 23, 35, 23); create_object("Shelf 10" , 5, 2000, 2048, 36, 23, 36, 23); create_object("Shelf 11" , 5, 2000, 4096, 37, 23, 37, 23); create_object("Shelf 12" , 5, 2000, 8192, 38, 23, 38, 23); create_object("Piano" , 3, 10000, 1, 33, 25, 35, 25); create_object("Left Desk" , 2, 5000, 1, 20, 25, 22, 27); create_object("Right Desk" , 2, 5000, 2, 36, 30, 38, 32); create_object("Left Chair" , 4, 2000, 1, 21, 28, 21, 28); create_object("Right Chair" , 4, 2000, 2, 37, 29, 37, 29); create_object("Painting 01" , 6, 3000, 1, 21, 20, 21, 20); create_object("Painting 02" , 6, 3000, 2, 23, 21, 23, 21); create_object("Painting 03" , 6, 3000, 4, 25, 20, 25, 20); create_object("Painting 04" , 6, 3000, 8, 28, 21, 28, 21); create_object("Painting 05" , 6, 3000, 16, 31, 20, 31, 20); create_object("Painting 06" , 6, 3000, 32, 36, 20, 36, 20); initnpctimer; end; // Load Mobilia already existing after 5 seconds OnTimer5000: debugmes "[REAL ESTATE] Now loading mobilia"; for (.@i=0; .@i < getarraysize(.layer); .@i++) { switch (.layer[.@i]) { case 1: if ($ESTATE_MOBILIA_128[.id] & .objid[.@i]) array_push(.valid_ids, .@i); break; case 2: if ($ESTATE_MOBILIA_4[.id] & .objid[.@i]) array_push(.valid_ids, .@i); break; case 3: if ($ESTATE_MOBILIA_8[.id] & .objid[.@i]) array_push(.valid_ids, .@i); break; case 4: if ($ESTATE_MOBILIA_32[.id] & .objid[.@i]) array_push(.valid_ids, .@i); break; case 5: if ($ESTATE_MOBILIA_64[.id] & .objid[.@i]) array_push(.valid_ids, .@i); break; case 6: if ($ESTATE_MOBILIA_2[.id] & .objid[.@i]) array_push(.valid_ids, .@i); break; default: // We do nothing by default //debugmes("[ERROR] [CRITICAL] [REAL ESTATE]: Object %d have Invalid Collision Type: %d (must range 1~6)", .@i, .layer[.@i]); break; } } debugmes "Found %d valid objects", getarraysize(.valid_ids); for (.@j=0; .@j < getarraysize(.valid_ids); .@j++) { .@id=.valid_ids[.@j]; setcells .mapa$, .x1[.@id], .y1[.@id], .x2[.@id], .y2[.@id], .layer[.@id], realestate_cellname(.id, .@id); debugmes "Creating %s in %s", realestate_cellname(.id, .@id), .mapa$; } deletearray .valid_ids; stopnpctimer; end; }