summaryrefslogtreecommitdiff
path: root/world
diff options
context:
space:
mode:
authorHoraK-FDF <horak-fdf@web.de>2023-07-07 01:57:38 +0000
committerLed Mitz <smoothshifter@tuta.io>2023-07-07 01:57:38 +0000
commitac308293e0e10f0762c9adffec5bb9c81cd52275 (patch)
treef6b67b68ce0191ed9c87dbdf5606d6a6d7d6018c /world
parent4f23b6a8f220bafe85516f3396261e4c13c2a8f1 (diff)
downloadserverdata-ac308293e0e10f0762c9adffec5bb9c81cd52275.tar.gz
serverdata-ac308293e0e10f0762c9adffec5bb9c81cd52275.tar.bz2
serverdata-ac308293e0e10f0762c9adffec5bb9c81cd52275.tar.xz
serverdata-ac308293e0e10f0762c9adffec5bb9c81cd52275.zip
Chronos Fix
Diffstat (limited to 'world')
-rw-r--r--world/map/db/const-quest.txt30
-rw-r--r--world/map/npc/099-7/boss.txt8
-rw-r--r--world/map/npc/099-7/chronos.txt73
-rw-r--r--world/map/npc/functions/clear_vars.txt16
4 files changed, 98 insertions, 29 deletions
diff --git a/world/map/db/const-quest.txt b/world/map/db/const-quest.txt
index aa8512ba..6f3f7148 100644
--- a/world/map/db/const-quest.txt
+++ b/world/map/db/const-quest.txt
@@ -129,16 +129,26 @@ FLAG_SANTAS_HELPER 1024 // player gave presents to Santa's helper
FLAG_HURNSMINE_CHEST 2048 // player opened the chest with the short sword in Hurnscald mines
FLAG_GOT_BEANIEHAT 4096 // player got Beanie Copter Hat from Milly
FLAG_DECLINED_BEANIEHAT 8192 // player declined Beanie Copter Hat from Milly
-FLAG_KESHLAM_FLAWEDLENS 16384 // player got the Flawed Lens from Keshlam's Chest
-FLAG_KESHLAM_RAREDROP 32768 // player got the super rare from Keshlam's Chest
-FLAG_BEHEADER_MASK 65536 // traded with The Beheader
-FLAG_GOT_BEHEADER_SWORD 131072 // Obtained the Beheader Sword
-FLAG_LUCA_GOT_SIX_SKILLS 262144 // player learned all six Focus Skills
-FLAG_LUCA_2SKILLS_MAXED 524288 // player got 2 Focus Skills at lvl 9
-FLAG_LUCA_4SKILLS_MAXED 1048576 // player got 4 Focus Skills at lvl 9
-FLAG_LUCA_6SKILLS_MAXED 2097152 // player got 6 Focus Skills at lvl 9
-FLAG_LUCA_FIX 4194304 // fixed a bug
-FLAG_XMAS21 8388608 // Christmas 2021 Rewards
+//FLAG_ 16384 // not used at the moment
+//FLAG_ 32768 // not used at the moment
+FLAG_BEHEADER_MASK 65536 // traded with The Beheader
+FLAG_GOT_BEHEADER_SWORD 131072 // Obtained the Beheader Sword
+FLAG_LUCA_GOT_SIX_SKILLS 262144 // player learned all six Focus Skills
+FLAG_LUCA_2SKILLS_MAXED 524288 // player got 2 Focus Skills at lvl 9
+FLAG_LUCA_4SKILLS_MAXED 1048576 // player got 4 Focus Skills at lvl 9
+FLAG_LUCA_6SKILLS_MAXED 2097152 // player got 6 Focus Skills at lvl 9
+FLAG_LUCA_FIX 4194304 // fixed a bug
+FLAG_XMAS21 8388608 // Christmas 2021 Rewards
+FLAG_KESHLAM_REPACKED 16777216 // Moved FLAG_KESHLAM_FLAWEDLENS (16384) and FLAG_KESHLAM_RAREDROP (32768) to KESHLAM_STATE
+
+// Flags set in the KESHLAM_STATE variable:
+FLAG_KESHLAM_FLAWEDLENS 65536 // player got the Flawed Lens from Keshlam's Chest
+FLAG_KESHLAM_RAREDROP 131072 // player got the super rare from Keshlam's Chest
+// Constants related to Chronos
+// BOSS_MEDALS is using bits 1-8 (BYTE_0_SHIFT, BYTE_0_MASK)
+// BOSS_MEDALS_AVAILABLE is using bits 9-16 (BYTE_1_SHIFT, BYTE_1_MASK)
+CHRONOS_BOSS_MEDALS_MAX 255
+// constants can only be -2147483648 till 2147483647 so its not possible to make the mask 4293918720
// Flags for the battle caves.
BATTLE_CAVE1 1
diff --git a/world/map/npc/099-7/boss.txt b/world/map/npc/099-7/boss.txt
index 3980b2bb..7d68bca8 100644
--- a/world/map/npc/099-7/boss.txt
+++ b/world/map/npc/099-7/boss.txt
@@ -657,7 +657,7 @@ OnTimer150000:
// Who wants a rare drop?
099-7,38,126,0|script|Chest#keshlam|111
{
- if (FLAGS & FLAG_KESHLAM_RAREDROP) goto L_Finished;
+ if (KESHLAM_STATE & FLAG_KESHLAM_RAREDROP) goto L_Finished;
mes "[Chest]";
mes "Would you try to open it?";
mes "##1Cost: 1000 Treasure Keys";
@@ -676,13 +676,13 @@ L_Yes:
&& countitem("TreasureKey") > 1000)
goto L_TooMany;
delitem "TreasureKey", 1000;
- if (FLAGS & FLAG_KESHLAM_FLAWEDLENS) goto L_Rare;
+ if (KESHLAM_STATE & FLAG_KESHLAM_FLAWEDLENS) goto L_Rare;
goto L_FlawedLens;
L_FlawedLens:
getitem "FlawedLens", 1;
getexp 30000000, 0;
- set FLAGS, FLAGS | FLAG_KESHLAM_FLAWEDLENS;
+ set KESHLAM_STATE, KESHLAM_STATE | FLAG_KESHLAM_FLAWEDLENS;
mes "[Chest]";
mes "You opened it and found...! Some flawed lens?! Meh.";
next;
@@ -693,7 +693,7 @@ L_FlawedLens:
L_Rare:
getexp 15000000, 0;
- set FLAGS, FLAGS | FLAG_KESHLAM_RAREDROP;
+ set KESHLAM_STATE, KESHLAM_STATE | FLAG_KESHLAM_RAREDROP;
if (rand(4) == 1) goto L_Amulet; // 25% chance
goto L_Ring; // 75% chance
diff --git a/world/map/npc/099-7/chronos.txt b/world/map/npc/099-7/chronos.txt
index ec3eef49..c0e0c9e8 100644
--- a/world/map/npc/099-7/chronos.txt
+++ b/world/map/npc/099-7/chronos.txt
@@ -1,4 +1,4 @@
-// Cronos, the lord of time and apparently a shopkeeper
+// Chronos, the lord of time and apparently a shopkeeper
// There's also Father Time in the GM stuff
099-7,95,27,0|script|Chronos|313
@@ -6,6 +6,7 @@
cleararray @items$, "", getarraysize(@items$); // must be cleared here if someone used the close button last time then items would remain in list
cleararray @item_names$, "", getarraysize(@item_names$);
cleararray @shopopt$, "", getarraysize(@shopopt$);
+
mes "[Chronos]";
mes "\"I'm Chronos, lord of time, the immortal, the head editor of the Almanach, the... Alright, let's forget that.\"";
if (BOSS_POINTS < .price) goto L_Close;
@@ -16,30 +17,69 @@
if ($CHRONOS_STOCK < 1) goto L_Maxed;
set @cur_date, 0;
next;
+
// Boss Points validation
set @cur, BOSS_POINTS / .price;
- set @dif, @cur - #BOSS_MEDALS;
+ set @BOSS_MEDALS, (KESHLAM_STATE & BYTE_0_MASK);
+ set @BOSS_MEDALS_AVAILABLE, (KESHLAM_STATE & BYTE_1_MASK) >> BYTE_1_SHIFT;
+ if ( @BOSS_MEDALS >= CHRONOS_BOSS_MEDALS_MAX) goto L_CantGiveMedals;
+
+ set @dif, @cur - @BOSS_MEDALS;
if (@dif >= 1) goto L_GiveMedals;
mes "[Chronos]";
mes "\"You haven't made any progress, so I can't give you any Boss Medals at this time.\"";
mes "";
+ goto L_CheckAvailableMedals;
+
+L_CantGiveMedals:
+ mes "[Chronos]";
+ mes "\"You reached the maximum possible Boss Medals I can keep track for you already so I will not look if you deserve more sorry.\"";
+ mes "";
+ goto L_CheckAvailableMedals;
- if (#BOSS_MEDALS_AVAILABLE >= 1) goto L_Qestion;
+L_CheckAvailableMedals:
+ if (@BOSS_MEDALS_AVAILABLE >= 1) goto L_Question;
mes "[Chronos]";
mes "\"Sadly there are no Boss Medals for you to do shopping left.\"";
goto L_Close;
L_GiveMedals:
- set #BOSS_MEDALS, #BOSS_MEDALS + @dif;
- set #BOSS_MEDALS_AVAILABLE, #BOSS_MEDALS_AVAILABLE + @dif;
+ set @BOSS_MEDALS, @BOSS_MEDALS + @dif;
+ if (@BOSS_MEDALS > CHRONOS_BOSS_MEDALS_MAX) goto L_ExededMaxMedals;
+ set @BOSS_MEDALS_AVAILABLE, @BOSS_MEDALS_AVAILABLE + @dif;
+ set KESHLAM_STATE, (KESHLAM_STATE & ~(BYTE_0_MASK + BYTE_1_MASK)) | @BOSS_MEDALS | @BOSS_MEDALS_AVAILABLE << BYTE_1_SHIFT;
mes "[Chronos]";
mes "\"For your deeds, I shall bestow upon you " + @dif + " Boss Medals. Use them wisely, they are the results of your hard effort.";
- mes "Boss Medals are earned each " + .price + " boss points. They are account-bound and cannot be given to other players, not even other versions of you.";
+ mes "Boss Medals are earned each " + .price + " boss points. They are character-bound and cannot be given to other players, not even other versions of you.";
mes "I will keep them for you until you evolved a bit.\"";
next;
- goto L_Qestion;
+ if (@BOSS_MEDALS == CHRONOS_BOSS_MEDALS_MAX) goto L_MaxedMedals;
+ goto L_Question;
-L_Qestion:
+L_MaxedMedals:
+ wgm "=> Player `"+strcharinfo(0) + "` reached maximum possible Boss Medals (" + CHRONOS_BOSS_MEDALS_MAX + ") from Chronos.";
+ debugmes "=> Player `"+strcharinfo(0) + "` reached maximum possible Boss Medals (" + CHRONOS_BOSS_MEDALS_MAX + ") from Chronos.";
+ mes "[Chronos]";
+ mes "\"Oh you just reached the maximum possible Boss Medals I can keep track for you this means I can't give you more in the future.";
+ mes "I just reached out telepatically to the invisible forces that keep this world into motion and told them what happened to you, so they are aware of your situation.\"";
+ next;
+ goto L_Question;
+
+L_ExededMaxMedals:
+ set @cur, CHRONOS_BOSS_MEDALS_MAX - (@BOSS_MEDALS - @dif);
+ set @BOSS_MEDALS, CHRONOS_BOSS_MEDALS_MAX;
+ set @BOSS_MEDALS_AVAILABLE, @BOSS_MEDALS_AVAILABLE + @cur;
+ set @dif, @dif - @cur;
+ set KESHLAM_STATE, (KESHLAM_STATE & ~(BYTE_0_MASK + BYTE_1_MASK)) | @BOSS_MEDALS | @BOSS_MEDALS_AVAILABLE << BYTE_1_SHIFT;
+ wgm "=> Player `"+strcharinfo(0) + "` exeded maximum possible Boss Medals (" + CHRONOS_BOSS_MEDALS_MAX + ") from Chronos by " + @dif + " .";
+ debugmes "=> Player `"+strcharinfo(0) + "` exeded maximum possible Boss Medals (" + CHRONOS_BOSS_MEDALS_MAX + ") from Chronos by " + @dif + " .";
+ mes "[Chronos]";
+ mes "\"Oh you just exeded the maximum possible Boss Medals I can keep track for you by " + @dif + " so I can only bestow upon you " + @cur + " Boss Medals now and this means I can't give you more in the future.";
+ mes "I just reached out telepatically to the invisible forces that keep this world into motion and told them what happened to you, maybe they can help you.\"";
+ next;
+ goto L_Question;
+
+L_Question:
// Shopkeeping
mes "[Chronos]";
mes "\"All things shall pass, but with the limited time you have, please enjoy shopkeeping.\"";
@@ -62,19 +102,19 @@ L_Shop:
set @shopoptcounter, 0;
setarray @shopopt$, "", "", "", "", "";
- if(#BOSS_MEDALS_AVAILABLE < 1) goto L_Close;
+ if(@BOSS_MEDALS_AVAILABLE < 1) goto L_Close;
set @shopopt$[@shopoptcounter], "1 Boss Medal";
set @shopoptcounter, @shopoptcounter + 1;
- if(#BOSS_MEDALS_AVAILABLE < 2) goto L_ShopMenuCreated;
+ if(@BOSS_MEDALS_AVAILABLE < 2) goto L_ShopMenuCreated;
set @shopopt$[@shopoptcounter], "2 Boss Medals";
set @shopoptcounter, @shopoptcounter + 1;
- if(#BOSS_MEDALS_AVAILABLE < 3) goto L_ShopMenuCreated;
+ if(@BOSS_MEDALS_AVAILABLE < 3) goto L_ShopMenuCreated;
set @shopopt$[@shopoptcounter], "3 Boss Medals";
set @shopoptcounter, @shopoptcounter + 1;
- if(#BOSS_MEDALS_AVAILABLE < 4) goto L_ShopMenuCreated;
+ if(@BOSS_MEDALS_AVAILABLE < 4) goto L_ShopMenuCreated;
set @shopopt$[@shopoptcounter], "4 Boss Medals";
set @shopoptcounter, @shopoptcounter + 1;
goto L_ShopMenuCreated;
@@ -83,7 +123,7 @@ L_ShopMenuCreated:
set @shopopt$[@shopoptcounter], "I must think about this again, good bye.";
mes "";
mes "[Chronos]";
- mes "\"You have " + #BOSS_MEDALS_AVAILABLE + " Boss Medals left.";
+ mes "\"You have " + @BOSS_MEDALS_AVAILABLE + " Boss Medals left.";
mes "For which amount of Boss Medals you want to get a reward?\"";
menu
@shopopt$[0], L_MenuItems,
@@ -173,7 +213,7 @@ L_rewards_choice:
"Yes", L_Yes;
// to prevent fast key pressers and clickers from doing an error put No first as it's the highlighted item then.
// but its not able to handle if someone moves the mouse on the wrong menu item and double clicks.
-
+
L_Yes:
getinventorylist;
if ((checkweight(@item$, 1) == 0) || (@inventorylist_count == 100)) goto L_InvFull;
@@ -184,7 +224,8 @@ L_Yes:
mes "\"Here's your " + @item_names$[@index] + ", good bye.\"";
wgm "=> Player `"+strcharinfo(0) + "` obtained the following item from Chronos: "+ @item_names$[@index];
debugmes "=> Player `"+strcharinfo(0) + "` obtained the following item from Chronos: "+ @item_names$[@index];
- set #BOSS_MEDALS_AVAILABLE, #BOSS_MEDALS_AVAILABLE - @num_medals;
+ set @BOSS_MEDALS_AVAILABLE, @BOSS_MEDALS_AVAILABLE - @num_medals;
+ set KESHLAM_STATE, (KESHLAM_STATE & ~BYTE_1_MASK) | @BOSS_MEDALS_AVAILABLE << BYTE_1_SHIFT;
set $CHRONOS_STOCK, $CHRONOS_STOCK - 1;
set @cur_date, (gettime(7) << 5) | (gettime(6) << 1);
set #CHRONOS, @cur_date;
@@ -206,6 +247,8 @@ L_InvFull:
goto L_Close;
L_Close:
+ set @BOSS_MEDALS, 0;
+ set @BOSS_MEDALS_AVAILABLE, 0;
set @cur, 0;
set @dif, 0;
set @num_medals, 0;
diff --git a/world/map/npc/functions/clear_vars.txt b/world/map/npc/functions/clear_vars.txt
index 00173429..23577434 100644
--- a/world/map/npc/functions/clear_vars.txt
+++ b/world/map/npc/functions/clear_vars.txt
@@ -18,6 +18,7 @@ function|script|ClearVariables
callsub S_Bitmask;
callsub S_BlueSage;
callsub S_Luca;
+ callsub S_Keshlam;
callsub S_Valentine2021;
@@ -80,6 +81,21 @@ S_LucaX:
set FLAGS, FLAGS | FLAG_LUCA_FIX;
return;
+S_Keshlam:
+ if (FLAGS & FLAG_KESHLAM_REPACKED) goto S_Return;
+ set KESHLAM_STATE, #BOSS_MEDALS | (#BOSS_MEDALS_AVAILABLE << BYTE_1_SHIFT);
+ set #BOSS_MEDALS, 0;
+ set #BOSS_MEDALS_AVAILABLE, 0;
+ // old
+ // FLAG_KESHLAM_FLAWEDLENS 16384 shift 14
+ // FLAG_KESHLAM_RAREDROP 32768 shift 15
+ // new
+ // FLAG_KESHLAM_FLAWEDLENS 65536 shift 16
+ // FLAG_KESHLAM_RAREDROP 131072 shift 17
+ set KESHLAM_STATE, KESHLAM_STATE | ((FLAGS & 16384) >> 14) << 16 | ((FLAGS & 32768) >> 15) << 17;
+ set FLAGS, FLAGS | FLAG_KESHLAM_REPACKED ^ 16384 ^ 32768;
+ return;
+
S_Flags:
if (Open_Underground_Palace_Barrier)
set FLAGS, FLAGS | FLAG_OPENED_UNDERGROUND;