summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-03-05 01:45:25 -0300
committerJesusaves <cpntb1@ymail.com>2019-03-05 01:45:25 -0300
commit46dd0a771facf04bb3ffb37d6aea1e9205d82ecb (patch)
treeef085f6103ebff5feb1c4210109a98d959dc0bac
parent3f44259523476583fd8ebafb256d843435a3eca9 (diff)
downloadserverdata-jesusalva/estate.tar.gz
serverdata-jesusalva/estate.tar.bz2
serverdata-jesusalva/estate.tar.xz
serverdata-jesusalva/estate.zip
Real Estate attains the expected functionality.jesusalva/estate
Now we still need utility NPCs (eg. Piano could allow change map music)
-rw-r--r--db/constants.conf8
-rw-r--r--npc/012-8/doorbell.txt145
2 files changed, 93 insertions, 60 deletions
diff --git a/db/constants.conf b/db/constants.conf
index f978b5605..a26946525 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -3883,6 +3883,14 @@ constants_db: {
MASK_UNUSED: 512
MASK_SPECIAL: 1024
+ comment__: "Real Estate Collisions"
+ RES_OBJECTS: 1
+ RES_UTILITIES: 5
+ RES_LUXURY: 3
+ RES_DECORATION: 2
+ RES_SITTABLE: 4
+ RES_WALLDECORATION: 6
+
comment__: "speechflags"
S_FIRST_BLANK_LINE: 1
S_LAST_BLANK_LINE: 2
diff --git a/npc/012-8/doorbell.txt b/npc/012-8/doorbell.txt
index 59eab6a3f..833872c05 100644
--- a/npc/012-8/doorbell.txt
+++ b/npc/012-8/doorbell.txt
@@ -112,10 +112,11 @@ L_Furniture:
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 Beds"),
+ l("Manage Utilities"),
+ l("Manage Luxury furniture"),
+ l("Manage Decoration"),
+ l("Manage Chairs"),
l("Manage Paintings");
mes "";
@@ -124,69 +125,92 @@ L_Furniture:
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)
- array_push(@valid_ids, .@i);
- }
- //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 (realestate_hasmobilia(.id, .layer[.@id], .objid[.@id])) {
- @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
+ mesc ".:: "+ l("Beds") + " ::.", 3;
+ @re_col=RES_OBJECTS;
break;
case 3:
- goto L_Furniture;
+ mesc ".:: "+ l("Utilities") + " ::.", 3;
+ @re_col=RES_UTILITIES;
break;
case 4:
+ mesc ".:: "+ l("Luxury furniture") + " ::.", 3;
+ @re_col=RES_LUXURY;
break;
+ case 5:
+ mesc ".:: "+ l("Decoration") + " ::.", 3;
+ @re_col=RES_DECORATION;
+ break;
+ case 6:
+ mesc ".:: "+ l("Chairs") + " ::.", 3;
+ @re_col=RES_SITTABLE;
+ break;
+ case 7:
+ mesc ".:: "+ l("Paintings") + " ::.", 3;
+ @re_col=RES_WALLDECORATION;
+ break;
+ }
+
+// L_ContinuousLoop
+// Requires the following variables:
+// @re_col
+// Target Collision ID
+L_ContinuousLoop:
+ deletearray @valid_ids;
+
+ // Create a second array (@valid_ids) with the ID of objects within @re_col group
+ 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)
+ array_push(@valid_ids, .@i);
+ }
+ //debugmes "Found %d valid objects", getarraysize(@valid_ids);
+
+ // Create the menu with @valid_ids - Check if you already have the item to decide if you're buying or selling
+ @menuentries$="Finish:";
+ for (.@j=0; .@j < getarraysize(@valid_ids); .@j++) {
+ .@i=@valid_ids[.@j];
+ if (realestate_hasmobilia(.id, .layer[.@i], .objid[.@i]))
+ @menuentries$+=l("Sell ")+.name$[.@i]+l(" for ") + format_number( realestate_sellprice(.id,.price[.@i]) ) +":";
+ else
+ @menuentries$+=l("Purchase ")+.name$[.@i]+(" for ") + format_number( .price[.@i] )+":";
+ }
+ select (@menuentries$);
+ mes "";
+
+ // First option to return to previous menu
+ if (@menu == 1)
+ goto L_Furniture;
+
+ // Otherwise, we know then that (@menu-2) is the ID in @valid_ids
+ // So we save .@id with the correct ID in object arrays.
+ // We also calculate how much aggregated money you have.
+ .@id=@valid_ids[@menu-2];
+ .@gp=REAL_ESTATE_CREDITS+Zeny;
+
+ if (realestate_hasmobilia(.id, .layer[.@id], .objid[.@id])) {
+ // If you have the mobilia, you're selling it for Mobiliary Credits
+ realestate_togglemobilia(.id, .layer[.@id], .objid[.@id]);
+ REAL_ESTATE_CREDITS+=realestate_sellprice(.id,.price[.@i]);
+ delcells realestate_cellname(.id, .@id);
+ mesc l("Sale successful!");
+ next;
+ } else {
+ // Else, you're buying it, so we must check if you have the moolah first
+ .@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;
+ }
}
- goto L_Furniture;
-L_FindLoop:
+ // This loops forever
+ goto L_ContinuousLoop;
OnInit:
@@ -212,6 +236,7 @@ OnInit:
// Furniture Settings
// Name, Collision Layer, Price, ID, x1, y1, x2, y2
+ // For Collision Layer, see constants.conf ("Real Estate Collisions")
create_object("Placeholder" ,99,999999,99999, 99, 99, 99, 99);
create_object("Bed 01" , 1, 5000, 1, 24, 24, 25, 27);