summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2020-08-14 08:47:40 -0400
committergumi <git@gumi.ca>2020-08-14 08:51:54 -0400
commit91afc1d23bdd6e92363e985f0838d90d4490c3e4 (patch)
treec8f28785a6457666fa3d94ed9d4049979a4fb60e
parent89bc00552ab22612082af78562b9b1b281cfb16a (diff)
downloadserverdata-91afc1d23bdd6e92363e985f0838d90d4490c3e4.tar.gz
serverdata-91afc1d23bdd6e92363e985f0838d90d4490c3e4.tar.bz2
serverdata-91afc1d23bdd6e92363e985f0838d90d4490c3e4.tar.xz
serverdata-91afc1d23bdd6e92363e985f0838d90d4490c3e4.zip
don't hardcode the recipe ingredients and return code
-rw-r--r--db/craft_db.conf40
-rw-r--r--npc/items/recipes.txt198
2 files changed, 84 insertions, 154 deletions
diff --git a/db/craft_db.conf b/db/craft_db.conf
index 4483b348..be1c95d8 100644
--- a/db/craft_db.conf
+++ b/db/craft_db.conf
@@ -57,6 +57,8 @@ craft_db: (
/*
TODO: allow ReturnCode to be a constant
FIXME: use a regex find-replace to change ReturnCode to the corresponding AegisName constants
+// Name: "Craft([^"]+)"\n\tFlag: "([^"]+)"\n\tReturnCode: [0-9]+
+// Name: "Craft$1"\n\tFlag: "$2"\n\tReturnCode: "$1"
*/
/**************
@@ -164,7 +166,7 @@ Boots: 700 --> 799
Id: 100
Name: "CraftCreasedShirt"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1300
+ ReturnCode: "CreasedShirt"
SourceItems:
(
{
@@ -189,7 +191,7 @@ Boots: 700 --> 799
Id: 101
Name: "CraftArtisTankTop"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1302
+ ReturnCode: "ArtisTankTop"
SourceItems:
(
{
@@ -214,7 +216,7 @@ Boots: 700 --> 799
Id: 102
Name: "CraftVneckJumper"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1301
+ ReturnCode: "VneckJumper"
SourceItems:
(
{
@@ -239,7 +241,7 @@ Boots: 700 --> 799
Id: 103
Name: "CraftSailorShirt"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1303
+ ReturnCode: "SailorShirt"
SourceItems:
(
{
@@ -264,7 +266,7 @@ Boots: 700 --> 799
Id: 104
Name: "CraftFineDress"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1308
+ ReturnCode: "FineDress"
SourceItems:
(
{
@@ -289,7 +291,7 @@ Boots: 700 --> 799
Id: 105
Name: "CraftSilkRobe"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1308
+ ReturnCode: "SilkRobe"
SourceItems:
(
{
@@ -314,7 +316,7 @@ Boots: 700 --> 799
Id: 106
Name: "CraftLegionTrainingShirt"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1304
+ ReturnCode: "LegionTrainingShirt"
SourceItems:
(
{
@@ -339,7 +341,7 @@ Boots: 700 --> 799
Id: 107
Name: "CraftForestArmor"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1306
+ ReturnCode: "ForestArmor"
SourceItems:
(
{
@@ -364,7 +366,7 @@ Boots: 700 --> 799
Id: 108
Name: "CraftLegionCopperArmor"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1305
+ ReturnCode: "LegionCopperArmor"
SourceItems:
(
{
@@ -389,7 +391,7 @@ Boots: 700 --> 799
Id: 109
Name: "CraftApprenticeRobe"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1312
+ ReturnCode: "ApprenticeRobe"
SourceItems:
(
{
@@ -414,7 +416,7 @@ Boots: 700 --> 799
Id: 110
Name: "CraftPeltJacket"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1319
+ ReturnCode: "PeltJacket"
SourceItems:
(
{
@@ -439,7 +441,7 @@ Boots: 700 --> 799
Id: 111
Name: "CraftChainmail"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1315
+ ReturnCode: "Chainmail"
SourceItems:
(
{
@@ -464,7 +466,7 @@ Boots: 700 --> 799
Id: 112
Name: "CraftSnakeplate"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1320
+ ReturnCode: "Snakeplate"
SourceItems:
(
{
@@ -489,7 +491,7 @@ Boots: 700 --> 799
Id: 113
Name: "CraftLightPlatemail"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1318
+ ReturnCode: "LightPlatemail"
SourceItems:
(
{
@@ -514,7 +516,7 @@ Boots: 700 --> 799
Id: 114
Name: "CraftJustifierChest"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1317
+ ReturnCode: "JustifierChest"
SourceItems:
(
{
@@ -539,7 +541,7 @@ Boots: 700 --> 799
Id: 115
Name: "CraftSorcererRobe"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1321
+ ReturnCode: "SorcererRobe"
SourceItems:
(
{
@@ -564,7 +566,7 @@ Boots: 700 --> 799
Id: 116
Name: "CraftLegionIronArmor"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1310
+ ReturnCode: "LegionIronArmor"
SourceItems:
(
{
@@ -589,7 +591,7 @@ Boots: 700 --> 799
Id: 117
Name: "CraftWarlordArmor"
Flag: "CRAFT_SMITHERY"
- ReturnCode: 1309
+ ReturnCode: "WarlordArmor"
SourceItems:
(
{
@@ -614,7 +616,7 @@ Boots: 700 --> 799
Id: 118
Name: "CraftWizardRobe"
Flag: "CRAFT_TAILORING"
- ReturnCode: 1323
+ ReturnCode: "WizardRobe"
SourceItems:
(
{
diff --git a/npc/items/recipes.txt b/npc/items/recipes.txt
index cde7d141..d0ef925a 100644
--- a/npc/items/recipes.txt
+++ b/npc/items/recipes.txt
@@ -5,50 +5,65 @@
// Description:
// Contains recipe books for Evol Online
-// showRecipe( Craft, Bonus, {amount 1, item 1}, {amount 2, item 2}... )
+// showRecipe( recipe{, recipe...} )
function script showRecipe {
- if ((getdatatype(getarg(1)) & DATATYPE_CONST) == 0) {
- // if the second argument is not a constant
- .@const$ = data_to_string(getarg(0));
+ freeloop(true);
+ for (.@a = 0; .@a < getargcount(); ++.@a) {
+ .@const$ = data_to_string(getarg(.@a));
if (startswith(.@const$, "Craft")) {
// infer the item constant from the craft constant
- .@recipe = getarg(0);
- .@item = string_to_data(substr(.@const$, 5, getstrlen(.@const$) - 5));
+ .@recipe = getarg(.@a);
+
+ .@item = string_to_data(substr(.@const$, 5, getstrlen(.@const$) - 1));
} else {
// infer the craft constant from the item constant
.@recipe = string_to_data(sprintf("Craft%s", .@const$));
- .@item = getarg(0);
+ .@item = getarg(.@a);
}
- .@start = 1;
+ if (.@item <= 0) {
+ // target item not found
+ continue;
+ }
- if (getargcount() < 3 || (getargcount() + 1) % 2 != 0) {
- return false; // invalid syntax
+ if (!RECIPES[.@recipe] && !debug) {
+ // does not have the recipe
+ continue;
}
- } else if (getargcount() < 4 || getargcount() % 2 != 0) {
- return false; // invalid syntax
- } else {
- .@recipe = getarg(0);
- .@item = getarg(1);
- .@start = 2;
- }
- if (RECIPES[.@recipe]) {
- if (.@item) {
+ for (.@inv = 0; .@inv < 9; ++.@inv) {
+ .@size = getcraftrecipe(.@recipe, .@inv, .@qty[0], .@item_id[0]);
+
+ if (.@size < 0) {
+ if (.@size == -1) {
+ // recipe does not exist
+ break;
+ }
+ // inventory does not exist
+ break;
+ }
+
mes(l(".:: %s Recipe ::.", getitemlink(.@item)));
- // TODO: add a script buildin to fetch recipe requirements
+ for (.@it = 0; .@it < .@size; ++.@it) {
+ .@recipe_item = .@item_id[.@it];
+ .@recipe_qty = .@qty[.@it];
+
+ if (.@recipe_item <= 0) {
+ break;
+ }
- for (.@i = .@start; .@i < getargcount(); .@i += 2) {
- mesc(l("%d/%d %s", countitem(getarg(.@i + 1)), getarg(.@i), getitemlink(getarg(.@i + 1))));
+ mesc(sprintf("%d/%d %s", countitem(.@recipe_item), .@recipe_qty, getitemlink(.@recipe_item)));
}
mes("");
+ .@count++;
}
- return true;
}
- return false;
+ freeloop(false);
+
+ return .@count > 0;
}
- script #RecipeBook NPC_HIDDEN,{
@@ -81,7 +96,7 @@ function read_book {
mesc l("Perhaps, in future, someone adds it to this world.");
break;
}
- next;
+ close2();
return;
}
@@ -97,21 +112,10 @@ function read_cooking {
mes "";
mes ".:: " + l("Sandwiches") + " ::.";
mes "";
- showRecipe(CraftCarpSandwich, CarpSandwich,
- 1, Bread,
- 3, LettuceLeaf,
- 2, Cheese,
- 1, CommonCarp);
- showRecipe(CraftPioulegSandwich, PioulegSandwich,
- 1, Bread,
- 3, LettuceLeaf,
- 2, Cheese,
- 1, PiouLegs);
- showRecipe(CraftMananaSandwich, MananaSandwich,
- 1, Bread,
- 3, LettuceLeaf,
- 2, Cheese,
- 1, Manana);
+
+ showRecipe(CarpSandwich,
+ PioulegSandwich,
+ MananaSandwich);
return;
}
@@ -130,46 +134,14 @@ function read_smithery {
mesf(".:: %s ::.", l("Chest Armor"));
mes();
- showRecipe(CraftLegionTrainingShirt, LegionTrainingShirt,
- 5, IronIngot,
- 1, CopperIngot,
- 5, Coal,
- 1, Knife);
- showRecipe(CraftLegionCopperArmor, LegionCopperArmor,
- 10, CopperIngot,
- 3, IronIngot,
- 10, Coal,
- 1, SharpKnife);
- showRecipe(CraftChainmail, Chainmail,
- 18, IronIngot,
- 3, SilverIngot,
- 20, Coal,
- 1, SharpKnife);
- showRecipe(CraftSnakeplate, Snakeplate,
- 55, SnakeScale,
- 3, IronIngot,
- 15, Moss,
- 1, SharpKnife);
- showRecipe(CraftLightPlatemail, LightPlatemail,
- 25, IronIngot,
- 5, SilverIngot,
- 25, Coal,
- 1, SharpKnife);
- showRecipe(CraftJustifierChest, JustifierChest,
- 3, RotoniumIngot,
- 40, CottonCloth,
- 20, Coal,
- 1, SharpKnife);
- showRecipe(CraftLegionIronArmor, LegionIronArmor,
- 30, IronIngot,
- 6, RotoniumIngot,
- 40, Coal,
- 1, Dagger);
- showRecipe(WarlordArmor,
- 11, RotoniumIngot,
- 20, SilverIngot,
- 50, Coal,
- 1, Dagger);
+ showRecipe(LegionTrainingShirt,
+ LegionCopperArmor,
+ Chainmail,
+ Snakeplate,
+ LightPlatemail,
+ JustifierChest,
+ LegionIronArmor,
+ WarlordArmor);
return;
}
@@ -185,61 +157,17 @@ function read_tailoring {
mesf(".:: %s ::.", l("Chest Armor"));
mes();
- showRecipe(CraftCreasedShirt, CreasedShirt,
- 1, CottonCloth,
- 15, PiouFeathers,
- 5, RattoTail,
- 1, Knife);
- showRecipe(CraftArtisTankTop, ArtisTankTop,
- 10, CottonCloth,
- 5, PiouFeathers,
- 5, Moss,
- 1, Knife);
- showRecipe(CraftVneckJumper, VneckJumper,
- 15, CottonCloth,
- 5, PiouFeathers,
- 7, Moss,
- 1, Knife);
- showRecipe(CraftSailorShirt, SailorShirt,
- 15, CottonCloth,
- 5, LeatherPatch,
- 5, Coal,
- 1, Knife);
- showRecipe(CraftFineDress, FineDress,
- 23, CottonCloth,
- 5, FluffyFur,
- 10, SilkCocoon,
- 1, Knife);
- showRecipe(CraftSilkRobe, SilkRobe,
- 40, SilkCocoon,
- 10, CottonCloth,
- 3, FluffyFur,
- 1, Knife);
- showRecipe(CraftForestArmor, ForestArmor,
- 10, LeatherPatch,
- 20, Moss,
- 3, TortugaShellFragment,
- 1, Knife);
- showRecipe(CraftApprenticeRobe, ApprenticeRobe,
- 10, CottonCloth,
- 70, SilkCocoon,
- 10, FluffyFur,
- 1, SharpKnife);
- showRecipe(CraftPeltJacket, PeltJacket,
- 25, SquirrelPelt,
- 10, LeatherPatch,
- 15, Moss,
- 1, SharpKnife);
- showRecipe(CraftSorcererRobe, SorcererRobe,
- 60, CottonCloth,
- 40, FluffyFur,
- 20, SilkCocoon,
- 1, Dagger);
- showRecipe(WizardRobe,
- 30, SquirrelPelt,
- 60, SilkCocoon,
- 5, LeatherPatch,
- 1, Dagger);
+ showRecipe(CreasedShirt,
+ ArtisTankTop,
+ VneckJumper,
+ SailorShirt,
+ FineDress,
+ SilkRobe,
+ ForestArmor,
+ ApprenticeRobe,
+ PeltJacket,
+ SorcererRobe,
+ WizardRobe);
return;
}