From 1623d7da9290f57bcd0dfe41f61a9581b5a78198 Mon Sep 17 00:00:00 2001 From: Jessica Tölke Date: Wed, 9 Jan 2013 18:12:52 +0100 Subject: Katze quest: use bitmasking to be able to remove the variable LastHiss. Nibble 0: Progress of quest Nibble 1: what was saved previously in LastHiss Add LastHiss to clear_vars Since the value in LastHiss is only needed to get some hint from Alice, taking over the value from LastHiss to Nibble 1 of Katze isn't needed. --- world/map/npc/015-1/alice.txt | 8 ++++-- world/map/npc/015-3/barrier.txt | 13 +++++++--- world/map/npc/015-3/katze.txt | 45 +++++++++++++++++++++------------- world/map/npc/015-3/pot.txt | 32 +++++++++++++++--------- world/map/npc/functions/clear_vars.txt | 2 ++ 5 files changed, 67 insertions(+), 33 deletions(-) diff --git a/world/map/npc/015-1/alice.txt b/world/map/npc/015-1/alice.txt index 18fdb4ba..34f728a1 100644 --- a/world/map/npc/015-1/alice.txt +++ b/world/map/npc/015-1/alice.txt @@ -2,17 +2,21 @@ // herbs. 015-1.gat,52,53,0|script|Alice|106,{ + + set @cat, ((Katze & NIBBLE_0_MASK) >> NIBBLE_0_SHIFT); + set @Hiss, ((Katze & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT); + mes "[Alice]"; mes "\"Greeting, fellow wanderer."; mes "Are you collecting herbs, too?\""; next; - if (LastHiss == 2 && Katze < 4) + if (@Hiss == 2 && @cat < 4) menu "Yes, sure.", L_findmany, "Herbs?", L_herbs, "Nope, just enjoying the scenery.", L_close, "I saw the cat, but it doesn't like me.", L_cat; - if (LastHiss == 1) + if (@Hiss == 1) menu "Yes, sure.", L_findmany, "Herbs?", L_herbs, diff --git a/world/map/npc/015-3/barrier.txt b/world/map/npc/015-3/barrier.txt index d0603c6c..5919fc2d 100644 --- a/world/map/npc/015-3/barrier.txt +++ b/world/map/npc/015-3/barrier.txt @@ -3,6 +3,7 @@ 015-3.gat,31,42,0|script|#CatCaveBarrier|45,1,1,{ + set @Hiss, ((Katze & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT); if (getequipid(equip_head) != 1217 && (getequipid(equip_head) > 0 || getequipid(equip_shield) > 0 @@ -16,15 +17,21 @@ || getequipid(equip_legs) > 0)) goto L_Not_Naked; - if (LastHiss != 2) + if (@Hiss != 2) mes "\"Hissss...\""; - set LastHiss, 2; + set @Hiss, 2; + callsub S_Update_Hiss; close; L_Not_Naked: warp "015-1.gat", 60, 32; - set LastHiss, 1; + set @Hiss, 1; + callsub S_Update_Hiss; mes "\"GRAAUWL! Hissss...\""; mes "Scared of what you hear, you flee back outside."; close; + +S_Update_Hiss: + set Katze, (Katze & ~(NIBBLE_1_MASK)) | (@Hiss << NIBBLE_1_SHIFT); + return; } diff --git a/world/map/npc/015-3/katze.txt b/world/map/npc/015-3/katze.txt index 8b258a8e..229e38f8 100644 --- a/world/map/npc/015-3/katze.txt +++ b/world/map/npc/015-3/katze.txt @@ -18,17 +18,19 @@ 015-3.gat,32,25,0|script|Katze|172,{ - if (Katze == 1 && @KatzeNeedsAlone == 0) goto L_NeedsFood; - if (Katze == 1) goto L_PreNeedsFood; - if (Katze == 2 && @KatzeNeedsAlone == 0) goto L_NeedsFur; - if (Katze == 2) goto L_PreNeedsFur; - if (Katze == 3) goto L_NeedsWood; - if (Katze == 4 && @KatzeNeedsAlone == 0) goto L_NeedsStuff; - if (Katze == 4) goto L_PreNeedsStuff; - if (Katze == 5) goto L_NeedsStuff2; - if (Katze == 6 && @KatzeNeedsAlone == 0) goto L_GainEars; - if (Katze == 6) goto L_PreGainEars; - if (Katze == 7) goto L_Finished; + set @cat, ((Katze & NIBBLE_0_MASK) >> NIBBLE_0_SHIFT); + + if (@cat == 1 && @catNeedsAlone == 0) goto L_NeedsFood; + if (@cat == 1) goto L_PreNeedsFood; + if (@cat == 2 && @catNeedsAlone == 0) goto L_NeedsFur; + if (@cat == 2) goto L_PreNeedsFur; + if (@cat == 3) goto L_NeedsWood; + if (@cat == 4 && @catNeedsAlone == 0) goto L_NeedsStuff; + if (@cat == 4) goto L_PreNeedsStuff; + if (@cat == 5) goto L_NeedsStuff2; + if (@cat == 6 && @catNeedsAlone == 0) goto L_GainEars; + if (@cat == 6) goto L_PreGainEars; + if (@cat == 7) goto L_Finished; L_NeedsMilk: mes "[Katze]"; @@ -39,7 +41,8 @@ L_NeedsMilk: close; L_ThrowStone: - set Katze, 0; + set @cat, 0; + callsub S_Update_Katze; percentheal -30, 0; warp "015-1.gat", 60, 32; mes "\"GRAAUWL! Hissss...\""; @@ -75,7 +78,8 @@ L_NeedsFur: L_MoveFur: delitem "WhiteFur", 1; - set Katze, 3; + set @cat, 3; + callsub S_Update_Katze; mes "The cat jumps at the fur! You quickly let go of it. The cat happily returns to its spot, carrying the fur in its mouth."; next; mes "The cat drops the fur and looks at you with half opened eyes. Suddenly she starts talking, and says: \"That was very kind of you.\" She seems to be smiling."; @@ -102,7 +106,8 @@ L_PreNeedsStuff: close; L_NeedsStuff: - set Katze, 5; + set @cat, 5; + callsub S_Update_Katze; mes "[Katze]"; mes "\"You've been really kind to me. I can make you something nice, but I will need"; mes "2 Snake Skins,"; @@ -162,8 +167,9 @@ L_GiveStuff: delitem "WhiteFur", 2; delitem "HardSpike", 2; delitem "TinyHealingPotion", 2; - set Katze, 6; - set @KatzeNeedsAlone, 1; + set @cat, 6; + callsub S_Update_Katze; + set @catNeedsAlone, 1; mes "[Katze]"; mes "\"Nicely done! Now leave me alone for a while, I need some time to prepare your present.\""; close; @@ -177,7 +183,8 @@ L_GainEars: getitem "CatEars", 1; set @xpval, 5000; getexp @xpval, 0; - set Katze, 7; + set @cat, 7; + callsub S_Update_Katze; mes "[Katze]"; mes "\"Look what I made for you! It makes you look a bit like me! Maybe it will give you a feeling of what it is like to be a cat.\""; mes "The cat winks at you."; @@ -191,4 +198,8 @@ L_Finished: if (getequipid(equip_head) != 1217) mes "\"Meow. Lost your ears?\""; close; + +S_Update_Katze: + set Katze, (Katze & ~(NIBBLE_0_MASK)) | (@cat << NIBBLE_0_SHIFT); + return; } diff --git a/world/map/npc/015-3/pot.txt b/world/map/npc/015-3/pot.txt index 926d5830..bb3c4b9c 100644 --- a/world/map/npc/015-3/pot.txt +++ b/world/map/npc/015-3/pot.txt @@ -2,23 +2,25 @@ 015-3.gat,37,29,0|script|Pot|127,{ + set @cat, ((Katze & NIBBLE_0_MASK) >> NIBBLE_0_SHIFT); + if (Katze > 0) mes "It's that old pot again."; if (Katze == 0) mes "It's a pot."; next; - if (Katze == 1 && @KatzeNeedsAlone == 0) + if (Katze == 1 && @catNeedsAlone == 0) goto L_NeedsFood; if (Katze == 1) goto L_HasMilk; - if (Katze == 2 && @KatzeNeedsAlone == 0) + if (Katze == 2 && @catNeedsAlone == 0) goto L_NeedsFur; if (Katze == 2) goto L_HasFood; if (Katze == 3) goto L_NeedsWood; - if (Katze == 4 && @KatzeNeedsAlone == 1) + if (Katze == 4 && @catNeedsAlone == 1) goto L_HasWood; if (Katze >= 4) goto L_Finished; @@ -32,8 +34,9 @@ L_NeedsMilk: L_GiveMilk: delitem "Milk", 1; - set Katze, 1; - set @KatzeNeedsAlone, 1; + set @cat, 1; + callsub S_Update_Katze; + set @catNeedsAlone, 1; close; L_HasMilk: @@ -61,14 +64,16 @@ L_NeedsFood: L_GiveChicken: delitem "ChickenLeg", 1; - set Katze, 2; - set @KatzeNeedsAlone, 1; + set @cat, 2; + callsub S_Update_Katze; + set @catNeedsAlone, 1; close; L_GiveSteak: delitem "Steak", 1; - set Katze, 2; - set @KatzeNeedsAlone, 1; + set @cat, 2; + callsub S_Update_Katze; + set @catNeedsAlone, 1; close; L_HasFood: @@ -98,8 +103,9 @@ L_NeedsWood: L_GiveWood: delitem "RawLog", 1; - set Katze, 4; - set @KatzeNeedsAlone, 1; + set @cat, 4; + callsub S_Update_Katze; + set @catNeedsAlone, 1; mes "You put the wooden log next to the pot. The cat eyes it suspiciously, but remains on her spot."; close; @@ -109,4 +115,8 @@ L_HasWood: L_Finished: close; + +S_Update_Katze: + set Katze, (Katze & ~(NIBBLE_0_MASK)) | (@cat << NIBBLE_0_SHIFT); + return; } diff --git a/world/map/npc/functions/clear_vars.txt b/world/map/npc/functions/clear_vars.txt index 71d81fcb..7188c2d8 100644 --- a/world/map/npc/functions/clear_vars.txt +++ b/world/map/npc/functions/clear_vars.txt @@ -101,6 +101,8 @@ function|script|ClearVariables|{ set QUEST_clothdyer_state, 0; // variable was moved to a temporary player variable set KatzeBeenOutside, 0; + // variable was moved to Nibble 1 of the variable Katze + set LastHiss, 0; //These lines are needed to migrate stuff from variables to flags if (Open_Underground_Palace_Barrier) -- cgit v1.2.3-60-g2f50