From 1bb7efd20540844d55d364306a5c1259745988e6 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 15 Apr 2019 13:37:29 -0300 Subject: Rewrite the Guild Alchemy System in a way which works (but is MESSY) --- npc/guilds/logs.txt | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'npc/guilds/logs.txt') diff --git a/npc/guilds/logs.txt b/npc/guilds/logs.txt index 29bb8b84b..c81789fb5 100644 --- a/npc/guilds/logs.txt +++ b/npc/guilds/logs.txt @@ -14,11 +14,11 @@ guilds,47,39,0 script Guild Logs NPC_NO_SPRITE,{ mes ".:: " + l("Alchemy Recipes") + " ::."; showRecipe(CraftPiberriesInfusion, PiberriesInfusion, 5, Piberries, 1, Curshroom); - showRecipe(CraftSacredManaPot, SacredManaPot, + showRecipe(CraftSacredManaPot, SacredManaPotion, 1, GoldenApple, 15, CelestiaTea); - showRecipe(CraftSacredLifePot, SacredLifePot, + showRecipe(CraftSacredLifePot, SacredLifePotion, 1, GoldenApple, 1, ElixirOfLife); - + debugmes "Okay"; if (getguildrole(.@gid, getcharid(3)) > GPOS_VICELEADER) close; @@ -26,7 +26,7 @@ guilds,47,39,0 script Guild Logs NPC_NO_SPRITE,{ { select l("Do nothing"), - rif(strcharinfo(0) == getguildmaster(.@gid), l("Raise max members")); + rif(strcharinfo(0) == getguildmaster(.@gid), l("Raise max members")), l("Learn Alchemy Recipes"); mes ""; @@ -78,15 +78,22 @@ guilds,47,39,0 script Guild Logs NPC_NO_SPRITE,{ // showRecipe (Craft, Bonus, Req1No, Req1Id, Req2No, Req2Id) // Bonus must NOT be zero to display text function showRecipe { - if ($RECIPES_ALCHEMY[getcharid(2)] & getarg(0)) { + /* + debugmes "Exist: %d", getd("$RECIPES_ALCHEMY_"+getcharid(2)+"["+getarg(0)+"]"); + debugmes "Seeking for slot %d on guild %d", getarg(0), getcharid(2); + */ + if (getd("$RECIPES_ALCHEMY_"+getcharid(2)+"["+getarg(0)+"]")) { + debugmes "Hooray! It exists! We have %d defined", getarg(1); if (getarg(1)) { mesn l("Craft @@", getitemlink(getarg(1))); mesc l("* @@ @@", getarg(2), getitemlink(getarg(3))); mesc l("* @@ @@", getarg(4), getitemlink(getarg(5))); mes ""; } + //debugmes "You got it: %d (global: %d)", getarg(0), $RECIPES_ALCHEMY[getcharid(2)]; return 1; } + //debugmes "Nope, nothing here"; return 0; } @@ -95,7 +102,7 @@ function calcRecipe { array_push(@tmp_alcrep_id, getarg(0)); array_push(@tmp_alcrep_glv, getarg(1)); array_push(@tmp_alcrep_ggp, getarg(2)); - array_push(@tmp_alcrep_txt$, getarg(3) + " - GLV "+getarg(1)+", "+getarg(2)+" GP"); + array_push(@tmp_alcrep_txt$, getarg(3) + " - GLV "+getarg(1)+", "+format_number(getarg(2))+" GP"); return; } @@ -105,18 +112,36 @@ function clearRecipe { deletearray(@tmp_alcrep_glv); deletearray(@tmp_alcrep_ggp); deletearray(@tmp_alcrep_txt$); + @tmp_alcrep_id[0]=-1; + @tmp_alcrep_glv[0]=-1; + @tmp_alcrep_ggp[0]=-1; + @tmp_alcrep_txt$[0]=l("Learn Nothing"); return; } // hudRecipe () function hudRecipe { + .@gid=getcharid(2); // Select - select (implode(@tmp_alcrep_txt$, ":")+":Nothing"); - if (@tmp_alcrep_glv[@menu] == 0) + select (implode(@tmp_alcrep_txt$, ":")); + @menu=@menu-1; + + /* DEBUG prints + debugmes "You choose: %d", @menu; + debugmes getd("$RECIPES_ALCHEMY_"+.@gid); + copyarray(.@v, getd("$RECIPES_ALCHEMY_"+.@gid), getarraysize(getd("$RECIPES_ALCHEMY_"+.@gid)) ); + debugmes "Width: %d (out of %d)", getarraysize(.@v), getarraysize(getd("$RECIPES_ALCHEMY_"+.@gid)); + debugmes "Slot 44: %d", .@v[44]; + debugmes "Slot 43: %d", .@v[43]; + debugmes "Slot 42: %d", .@v[42]; + debugmes "GLVL Options: %d-%d-%d-%d", @tmp_alcrep_glv[0], @tmp_alcrep_glv[1], @tmp_alcrep_glv[2], @tmp_alcrep_glv[3]; + */ + + if (@tmp_alcrep_glv[@menu] <= 0) return 1; if (getguildlvl(.@gid) < @tmp_alcrep_glv[@menu]) { - mesc l("Insufficient Guild Level!"), 1; + mesc l("Insufficient Guild Level! (@@/@@)", getguildlvl(.@gid), @tmp_alcrep_glv[@menu]), 1; next; return 0; } @@ -127,7 +152,7 @@ function hudRecipe { } // All fine, proceed $GUILD_BANK[.@gid] -= @tmp_alcrep_ggp[@menu]; - $RECIPES_ALCHEMY[getcharid(2)]=$RECIPES_ALCHEMY[getcharid(2)]|@tmp_alcrep_id[@menu]; + setd("$RECIPES_ALCHEMY_"+getcharid(2)+"["+@tmp_alcrep_id[@menu]+"]", true); mesc l("Skill learnt!"), 2; next; return 0; -- cgit v1.2.3-70-g09d2