summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-01-26 15:33:44 -0200
committerJesusaves <cpntb1@ymail.com>2019-01-26 15:33:44 -0200
commit7c33d9f46270227afdc29c2203b47495463429f2 (patch)
treea328668b4fc303537eefa085d412226afc4214bf
parent2837174f65d7ab1a749d3ac3ac9d4f8fd88fe4cc (diff)
downloadserverdata-7c33d9f46270227afdc29c2203b47495463429f2.tar.gz
serverdata-7c33d9f46270227afdc29c2203b47495463429f2.tar.bz2
serverdata-7c33d9f46270227afdc29c2203b47495463429f2.tar.xz
serverdata-7c33d9f46270227afdc29c2203b47495463429f2.zip
Ok, random treasure chests works, scatter them on the major dungeons.
-rw-r--r--npc/003-1-1/_import.txt1
-rw-r--r--npc/003-1-1/treasure.txt62
-rw-r--r--npc/007-1/treasure.txt38
-rw-r--r--npc/010-1-1/_import.txt1
-rw-r--r--npc/010-1-1/treasure.txt62
-rw-r--r--npc/011-1/_import.txt1
-rw-r--r--npc/011-1/treasure.txt9
-rw-r--r--npc/015-1/_import.txt1
-rw-r--r--npc/015-1/treasure.txt8
-rw-r--r--npc/015-5/_import.txt1
-rw-r--r--npc/015-5/treasure.txt65
-rw-r--r--npc/015-6/_import.txt1
-rw-r--r--npc/015-6/treasure.txt65
-rw-r--r--npc/018-3/_import.txt1
-rw-r--r--npc/018-3/treasure.txt65
-rw-r--r--npc/functions/treasure.txt49
-rw-r--r--npc/scripts.conf1
17 files changed, 394 insertions, 37 deletions
diff --git a/npc/003-1-1/_import.txt b/npc/003-1-1/_import.txt
index b87b04248..3acc019ee 100644
--- a/npc/003-1-1/_import.txt
+++ b/npc/003-1-1/_import.txt
@@ -2,4 +2,5 @@
// This file is generated automatically. All manually added changes will be removed when running the Converter.
"npc/003-1-1/_mobs.txt",
"npc/003-1-1/_warps.txt",
+"npc/003-1-1/treasure.txt",
"npc/003-1-1/yetiking.txt",
diff --git a/npc/003-1-1/treasure.txt b/npc/003-1-1/treasure.txt
new file mode 100644
index 000000000..ead0cfeaa
--- /dev/null
+++ b/npc/003-1-1/treasure.txt
@@ -0,0 +1,62 @@
+// TMW2 Script
+
+// (Random) Treasure Chest
+// Authored by Jesusalva
+// Regenerates every 6 hours
+
+003-1-1,0,0,0 script #chest_003110 NPC_CHEST,{
+
+ if (!.busy && !.empty) {
+ TreasureBox();
+
+ .empty=true;
+ specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
+ .dir = .dir == 0 ? 2 : 6; // closed ? opening : closing
+ .busy = true; // lock until available again
+ initnpctimer;
+ } else if (!.busy) {
+ mesc l("Someone looted this treasure box already...");
+ } else {
+ end;
+ }
+ close;
+
+OnTimer160:
+ .dir = .dir == 6 ? 0 : 4; // closing ? closed : open
+ end;
+
+OnTimer500:
+ .busy = false; // unlock
+ if (.dir == 0 || .dir == 4)
+ stopnpctimer; // stop here if the chest is closed
+ end;
+
+OnInit:
+ .busy = false;
+ .distance = 2;
+ .empty = false;
+
+OnClock0156:
+OnClock0756:
+OnClock1356:
+OnClock1956:
+ // Try to warp randomly to a walkable spot, up to 20 attempts
+ // Otherwise, it'll stay where it already is (but will close and refill).
+ .@e=0; .@x=0; .@y=0;
+ while (!checkcell(.map$, .@x, .@y, cell_chkpass))
+ {
+ if (.@e == 20) {
+ .@x=.x;
+ .@y=.y;
+ break;
+ }
+ // Remember the +20 -20 margin adjustment
+ .@x = rand(20, 160);
+ .@y = rand(20, 150);
+ ++.@e;
+ }
+ .busy=false;
+ .empty=false;
+ movenpc .name$, .@x, .@y, 0;
+ end;
+}
diff --git a/npc/007-1/treasure.txt b/npc/007-1/treasure.txt
index 0f8397651..96ed036e2 100644
--- a/npc/007-1/treasure.txt
+++ b/npc/007-1/treasure.txt
@@ -31,43 +31,7 @@ OnInit:
007-1,0,0,0 script #chest_00710 NPC_CHEST,{
if (!.busy && !.empty) {
- mesc l("Open the chest?");
- mesc l("Cost: 1 @@", getitemlink(TreasureKey)), 1;
- if (!countitem(TreasureKey))
- close;
- next;
- if (askyesno() == ASK_NO)
- close;
-
- delitem TreasureKey, 1;
- mesc l("You open the chest!");
- if (!.empty) {
- TREASURE_OPEN=TREASURE_OPEN+1;
- .@t=TREASURE_OPEN;
- .@r=rand(0,10000);
-
- // Select treasure list
- // You're warranted an ultra rare (0.1%) every 99 open chests
- // You're warranted a super rare (1%) every 50 open chests
- // There's also rares (10%), uncommons (40%) and commons (60%)
- if (.@t % 99 == 0 || .@r < 10)
- .@loot=any(AtroposMixture, GoldenApple, DivineApple, MercBoxA, SilverGift, Shemagh, EverburnPowder, IridiumOre, PlatinumOre);
- else if (.@t % 50 == 0 || .@r < 100)
- .@loot=any(Grenade, SnakeEgg, LachesisBrew, ArrowAmmoBox, CoinBag, BronzeGift, TerraniteOre, LeadOre, TinOre, SilverOre, GoldOre, TitaniumOre, FluoPowder);
- else if (.@r < 1000)
- .@loot=any(MoubooSteak, ClothoLiquor, Coal, SmallMushroom, HastePotion, StrengthPotion, Dagger, StrangeCoin, IronOre, CopperOre);
- else if (.@r < 4000)
- .@loot=any(Croconut, Potatoz, MoubooSteak, ClothoLiquor, Coal, SmallMushroom, HastePotion, StrengthPotion, StrangeCoin);
- else
- .@loot=any(FatesPotion, ChocolateBar, Plushroom, Chagashroom, RawLog, LeatherPatch);
-
-
- inventoryplace .@loot, 1;
- mesc l("You find @@ inside!", getitemlink(.@loot));
- getitem .@loot, 1;
- } else {
- mesc l("You find @@ inside!", l("nothing"));
- }
+ TreasureBox();
.empty=true;
specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
diff --git a/npc/010-1-1/_import.txt b/npc/010-1-1/_import.txt
index 42f1be217..166185523 100644
--- a/npc/010-1-1/_import.txt
+++ b/npc/010-1-1/_import.txt
@@ -2,3 +2,4 @@
// This file is generated automatically. All manually added changes will be removed when running the Converter.
"npc/010-1-1/_mobs.txt",
"npc/010-1-1/_warps.txt",
+"npc/010-1-1/treasure.txt",
diff --git a/npc/010-1-1/treasure.txt b/npc/010-1-1/treasure.txt
new file mode 100644
index 000000000..dfa86c9ea
--- /dev/null
+++ b/npc/010-1-1/treasure.txt
@@ -0,0 +1,62 @@
+// TMW2 Script
+
+// (Random) Treasure Chest
+// Authored by Jesusalva
+// Regenerates every 6 hours
+
+010-1-1,0,0,0 script #chest_010110 NPC_CHEST,{
+
+ if (!.busy && !.empty) {
+ TreasureBox();
+
+ .empty=true;
+ specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
+ .dir = .dir == 0 ? 2 : 6; // closed ? opening : closing
+ .busy = true; // lock until available again
+ initnpctimer;
+ } else if (!.busy) {
+ mesc l("Someone looted this treasure box already...");
+ } else {
+ end;
+ }
+ close;
+
+OnTimer160:
+ .dir = .dir == 6 ? 0 : 4; // closing ? closed : open
+ end;
+
+OnTimer500:
+ .busy = false; // unlock
+ if (.dir == 0 || .dir == 4)
+ stopnpctimer; // stop here if the chest is closed
+ end;
+
+OnInit:
+ .busy = false;
+ .distance = 2;
+ .empty = false;
+
+OnClock0156:
+OnClock0756:
+OnClock1356:
+OnClock1956:
+ // Try to warp randomly to a walkable spot, up to 20 attempts
+ // Otherwise, it'll stay where it already is (but will close and refill).
+ .@e=0; .@x=0; .@y=0;
+ while (!checkcell(.map$, .@x, .@y, cell_chkpass))
+ {
+ if (.@e == 20) {
+ .@x=.x;
+ .@y=.y;
+ break;
+ }
+ // Remember the +20 -20 margin adjustment
+ .@x = rand(20, 180);
+ .@y = rand(20, 120);
+ ++.@e;
+ }
+ .busy=false;
+ .empty=false;
+ movenpc .name$, .@x, .@y, 0;
+ end;
+}
diff --git a/npc/011-1/_import.txt b/npc/011-1/_import.txt
index 2545a2de2..258abb6da 100644
--- a/npc/011-1/_import.txt
+++ b/npc/011-1/_import.txt
@@ -3,3 +3,4 @@
"npc/011-1/_mobs.txt",
"npc/011-1/_warps.txt",
"npc/011-1/manastone.txt",
+"npc/011-1/treasure.txt",
diff --git a/npc/011-1/treasure.txt b/npc/011-1/treasure.txt
new file mode 100644
index 000000000..8b2eb8e0b
--- /dev/null
+++ b/npc/011-1/treasure.txt
@@ -0,0 +1,9 @@
+// TMW2 Script
+
+// (Random) Treasure Chest
+// Authored by Jesusalva
+// Regenerates every 6 hours
+
+011-1,0,0,0 duplicate(#chest_00710) #chest_01110 NPC_CHEST
+011-1,0,0,0 duplicate(#chest_00710) #chest_01111 NPC_CHEST
+
diff --git a/npc/015-1/_import.txt b/npc/015-1/_import.txt
index b247616e1..19aefef50 100644
--- a/npc/015-1/_import.txt
+++ b/npc/015-1/_import.txt
@@ -2,3 +2,4 @@
// This file is generated automatically. All manually added changes will be removed when running the Converter.
"npc/015-1/_mobs.txt",
"npc/015-1/_warps.txt",
+"npc/015-1/treasure.txt",
diff --git a/npc/015-1/treasure.txt b/npc/015-1/treasure.txt
new file mode 100644
index 000000000..6812d3b73
--- /dev/null
+++ b/npc/015-1/treasure.txt
@@ -0,0 +1,8 @@
+// TMW2 Script
+
+// (Random) Treasure Chest
+// Authored by Jesusalva
+// Regenerates every 6 hours
+
+015-1,0,0,0 duplicate(#chest_00710) #chest_01510 NPC_CHEST
+
diff --git a/npc/015-5/_import.txt b/npc/015-5/_import.txt
index de4f5e1c2..85922cc0b 100644
--- a/npc/015-5/_import.txt
+++ b/npc/015-5/_import.txt
@@ -3,3 +3,4 @@
"npc/015-5/_mobs.txt",
"npc/015-5/_warps.txt",
"npc/015-5/sign.txt",
+"npc/015-5/treasure.txt",
diff --git a/npc/015-5/treasure.txt b/npc/015-5/treasure.txt
new file mode 100644
index 000000000..105d4264f
--- /dev/null
+++ b/npc/015-5/treasure.txt
@@ -0,0 +1,65 @@
+// TMW2 Script
+
+// (Random) Treasure Chest
+// Authored by Jesusalva
+// Regenerates every 6 hours
+
+015-5,0,0,0 script #chest_01550 NPC_CHEST,{
+
+ if (!.busy && !.empty) {
+ TreasureBox();
+
+ .empty=true;
+ specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
+ .dir = .dir == 0 ? 2 : 6; // closed ? opening : closing
+ .busy = true; // lock until available again
+ initnpctimer;
+ } else if (!.busy) {
+ mesc l("Someone looted this treasure box already...");
+ } else {
+ end;
+ }
+ close;
+
+OnTimer160:
+ .dir = .dir == 6 ? 0 : 4; // closing ? closed : open
+ end;
+
+OnTimer500:
+ .busy = false; // unlock
+ if (.dir == 0 || .dir == 4)
+ stopnpctimer; // stop here if the chest is closed
+ end;
+
+OnInit:
+ .busy = false;
+ .distance = 2;
+ .empty = false;
+
+OnClock0156:
+OnClock0756:
+OnClock1356:
+OnClock1956:
+ // Try to warp randomly to a walkable spot, up to 20 attempts
+ // Otherwise, it'll stay where it already is (but will close and refill).
+ .@e=0; .@x=0; .@y=0;
+ while (!checkcell(.map$, .@x, .@y, cell_chkpass))
+ {
+ if (.@e == 20) {
+ .@x=.x;
+ .@y=.y;
+ break;
+ }
+ // Remember the +20 -20 margin adjustment
+ .@x = rand(20, 405);
+ .@y = rand(20, 190);
+ ++.@e;
+ }
+ .busy=false;
+ .empty=false;
+ movenpc .name$, .@x, .@y, 0;
+ end;
+}
+
+015-5,0,0,0 duplicate(#chest_01550) #chest_01551 NPC_CHEST
+
diff --git a/npc/015-6/_import.txt b/npc/015-6/_import.txt
index cebd2b9d2..733918207 100644
--- a/npc/015-6/_import.txt
+++ b/npc/015-6/_import.txt
@@ -3,3 +3,4 @@
"npc/015-6/_mobs.txt",
"npc/015-6/_warps.txt",
"npc/015-6/mapflags.txt",
+"npc/015-6/treasure.txt",
diff --git a/npc/015-6/treasure.txt b/npc/015-6/treasure.txt
new file mode 100644
index 000000000..5fc1a1c0f
--- /dev/null
+++ b/npc/015-6/treasure.txt
@@ -0,0 +1,65 @@
+// TMW2 Script
+
+// (Random) Treasure Chest
+// Authored by Jesusalva
+// Regenerates every 6 hours
+
+015-6,0,0,0 script #chest_01560 NPC_CHEST,{
+
+ if (!.busy && !.empty) {
+ TreasureBox();
+
+ .empty=true;
+ specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
+ .dir = .dir == 0 ? 2 : 6; // closed ? opening : closing
+ .busy = true; // lock until available again
+ initnpctimer;
+ } else if (!.busy) {
+ mesc l("Someone looted this treasure box already...");
+ } else {
+ end;
+ }
+ close;
+
+OnTimer160:
+ .dir = .dir == 6 ? 0 : 4; // closing ? closed : open
+ end;
+
+OnTimer500:
+ .busy = false; // unlock
+ if (.dir == 0 || .dir == 4)
+ stopnpctimer; // stop here if the chest is closed
+ end;
+
+OnInit:
+ .busy = false;
+ .distance = 2;
+ .empty = false;
+
+OnClock0156:
+OnClock0756:
+OnClock1356:
+OnClock1956:
+ // Try to warp randomly to a walkable spot, up to 20 attempts
+ // Otherwise, it'll stay where it already is (but will close and refill).
+ .@e=0; .@x=0; .@y=0;
+ while (!checkcell(.map$, .@x, .@y, cell_chkpass))
+ {
+ if (.@e == 20) {
+ .@x=.x;
+ .@y=.y;
+ break;
+ }
+ // Remember the +20 -20 margin adjustment
+ .@x = rand(20, 500);
+ .@y = rand(20, 190);
+ ++.@e;
+ }
+ .busy=false;
+ .empty=false;
+ movenpc .name$, .@x, .@y, 0;
+ end;
+}
+
+015-6,0,0,0 duplicate(#chest_01560) #chest_01561 NPC_CHEST
+
diff --git a/npc/018-3/_import.txt b/npc/018-3/_import.txt
index 97be42bc6..54aa6695c 100644
--- a/npc/018-3/_import.txt
+++ b/npc/018-3/_import.txt
@@ -2,3 +2,4 @@
// This file is generated automatically. All manually added changes will be removed when running the Converter.
"npc/018-3/_mobs.txt",
"npc/018-3/_warps.txt",
+"npc/018-3/treasure.txt",
diff --git a/npc/018-3/treasure.txt b/npc/018-3/treasure.txt
new file mode 100644
index 000000000..002f16b67
--- /dev/null
+++ b/npc/018-3/treasure.txt
@@ -0,0 +1,65 @@
+// TMW2 Script
+
+// (Random) Treasure Chest
+// Authored by Jesusalva
+// Regenerates every 6 hours
+
+018-3,0,0,0 script #chest_01830 NPC_CHEST,{
+
+ if (!.busy && !.empty) {
+ TreasureBox();
+
+ .empty=true;
+ specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
+ .dir = .dir == 0 ? 2 : 6; // closed ? opening : closing
+ .busy = true; // lock until available again
+ initnpctimer;
+ } else if (!.busy) {
+ mesc l("Someone looted this treasure box already...");
+ } else {
+ end;
+ }
+ close;
+
+OnTimer160:
+ .dir = .dir == 6 ? 0 : 4; // closing ? closed : open
+ end;
+
+OnTimer500:
+ .busy = false; // unlock
+ if (.dir == 0 || .dir == 4)
+ stopnpctimer; // stop here if the chest is closed
+ end;
+
+OnInit:
+ .busy = false;
+ .distance = 2;
+ .empty = false;
+
+OnClock0156:
+OnClock0756:
+OnClock1356:
+OnClock1956:
+ // Try to warp randomly to a walkable spot, up to 20 attempts
+ // Otherwise, it'll stay where it already is (but will close and refill).
+ .@e=0; .@x=0; .@y=0;
+ while (!checkcell(.map$, .@x, .@y, cell_chkpass))
+ {
+ if (.@e == 20) {
+ .@x=.x;
+ .@y=.y;
+ break;
+ }
+ // Remember the +20 -20 margin adjustment
+ .@x = rand(20, 130);
+ .@y = rand(20, 130);
+ ++.@e;
+ }
+ .busy=false;
+ .empty=false;
+ movenpc .name$, .@x, .@y, 0;
+ end;
+}
+
+018-3,0,0,0 duplicate(#chest_01830) #chest_01831 NPC_CHEST
+
diff --git a/npc/functions/treasure.txt b/npc/functions/treasure.txt
new file mode 100644
index 000000000..952f2973c
--- /dev/null
+++ b/npc/functions/treasure.txt
@@ -0,0 +1,49 @@
+// TMW2 functions.
+// Author:
+// Jesusalva
+// Description:
+// Random Treasure Box Utils
+
+function script TreasureBox {
+ mesc l("Open the chest?");
+ mesc l("Cost: 1 @@", getitemlink(TreasureKey)), 1;
+ if (!countitem(TreasureKey))
+ close;
+ next;
+ if (askyesno() == ASK_NO)
+ close;
+
+ delitem TreasureKey, 1;
+ mesc l("You open the chest!");
+
+ .@empty=getvariableofnpc(.empty, strnpcinfo(0));
+ if (!.@empty) {
+ TREASURE_OPEN=TREASURE_OPEN+1;
+ .@t=TREASURE_OPEN;
+ .@r=rand(0,10000);
+
+ // Select treasure list
+ // You're warranted an ultra rare (0.1%) every 99 open chests
+ // You're warranted a super rare (1%) every 50 open chests
+ // There's also rares (10%), uncommons (40%) and commons (60%)
+ if (.@t % 99 == 0 || .@r < 10)
+ .@loot=any(AtroposMixture, GoldenApple, DivineApple, MercBoxA, SilverGift, Shemagh, EverburnPowder, IridiumOre, PlatinumOre);
+ else if (.@t % 50 == 0 || .@r < 100)
+ .@loot=any(Grenade, SnakeEgg, LachesisBrew, ArrowAmmoBox, CoinBag, BronzeGift, TerraniteOre, LeadOre, TinOre, SilverOre, GoldOre, TitaniumOre, FluoPowder);
+ else if (.@r < 1000)
+ .@loot=any(MoubooSteak, ClothoLiquor, Coal, SmallMushroom, HastePotion, StrengthPotion, Dagger, StrangeCoin, IronOre, CopperOre);
+ else if (.@r < 4000)
+ .@loot=any(Croconut, Potatoz, MoubooSteak, ClothoLiquor, Coal, SmallMushroom, HastePotion, StrengthPotion, StrangeCoin);
+ else
+ .@loot=any(FatesPotion, ChocolateBar, Plushroom, Chagashroom, RawLog, LeatherPatch, BugLeg, ScorpionStinger, SmallKnife);
+
+
+ inventoryplace .@loot, 1;
+ mesc l("You find @@ inside!", getitemlink(.@loot));
+ getitem .@loot, 1;
+ } else {
+ mesc l("You find @@ inside!", l("nothing"));
+ }
+
+}
+
diff --git a/npc/scripts.conf b/npc/scripts.conf
index 2fcd1a3ff..b6589b239 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -55,6 +55,7 @@
"npc/functions/shake.txt",
"npc/functions/shops.txt",
"npc/functions/soul_menhir.txt",
+"npc/functions/treasure.txt",
// Item functions
"npc/items/books.txt",