diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-07-10 16:32:39 +0000 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-07-10 16:32:39 +0000 |
commit | 055ae0a6bb07db30f81236b34ae9ecea56249bbe (patch) | |
tree | 2c2927704c9b8cd6c0e01fa661e6f590f373c317 /npc/functions | |
parent | b2d6cf5a3c1a1547d1017e45a37e6492639b7f00 (diff) | |
download | serverdata-055ae0a6bb07db30f81236b34ae9ecea56249bbe.tar.gz serverdata-055ae0a6bb07db30f81236b34ae9ecea56249bbe.tar.bz2 serverdata-055ae0a6bb07db30f81236b34ae9ecea56249bbe.tar.xz serverdata-055ae0a6bb07db30f81236b34ae9ecea56249bbe.zip |
Implements Crafting Core system
Recipes etc. not included
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/crafting.txt | 94 | ||||
-rw-r--r-- | npc/functions/main.txt | 19 | ||||
-rw-r--r-- | npc/functions/quest-debug/055-General_Cooking.txt | 14 |
3 files changed, 120 insertions, 7 deletions
diff --git a/npc/functions/crafting.txt b/npc/functions/crafting.txt new file mode 100644 index 00000000..ba032f41 --- /dev/null +++ b/npc/functions/crafting.txt @@ -0,0 +1,94 @@ +// Moubootaur Legends Script +// Author: +// Jesusalva +// Description: +// Smith System (Unified) +// Notes: +// Modified for The Mana World: rEvolt +// +// This one is more crazy. Cannot be equipping target craft. +// After successful craft, we use CraftDB return code to equip() the +// new item and apply a random option bonus based on crafter skills +// eg. setequipoption(EQI_HAND_R, 1, VAR_STRAMOUNT, 5) + +// Usage: SmithSystem ({scope=CRAFT_SMITHERY, checks=True}) +// Returns true on success, false on failure +function script SmithSystem { + .@scope=getarg(0, CRAFT_SMITHERY); + mesc l("WARNING: Strange bugs may happen if you attempt to craft an item you already have on inventory!"), 1; + setskin "craft4"; + .@var$ = requestcraft(4); + .@craft = initcraft(.@var$); + .@entry = findcraftentry(.@craft, .@scope); + if (debug || $@GM_OVERRIDE) mes "found craft entry: " + .@entry; + if (debug || $@GM_OVERRIDE) mes "knowledge value: " + .knowledge[.@entry]; + if (.@entry < 0) { + .success=false; + } else { + if (!getarg(1, true) || RECIPES[.@entry]) { + // Player craft item and setup base variables + usecraft .@craft; + .@it=getcraftcode(.@entry); + .@lv=getiteminfo(.@it, ITEMINFO_ELV); + .@skill=getskilllv(EVOL_CRAFTING); + + // Update your CRAFTING_SCORE + CRAFTING_SCORE+=.@lv; + + // Obtain the item. No bounds or restrictions applied. + getitem(.@it, 1); + + // This is where we add options - this is oversimplified + // delinventorylist() is needed, because we'll rely on rfind() + delinventorylist(); + getinventorylist(); + .@index=array_rfind(@inventorylist_id, .@it); + + // Prepare the options + .@isweapon=(getiteminfo(.@it, ITEMINFO_TYPE) == IT_WEAPON); + .@bonus=(.@isweapon ? VAR_ATTPOWER : VAR_ITEMDEFPOWER); + .@magic=(.@isweapon ? VAR_ATTMPOWER : VAR_MDEFPOWER); + .@buffs=(.@isweapon ? VAR_HITSUCCESSVALUE : VAR_AVOIDSUCCESSVALUE); + .@heals=(.@isweapon ? VAR_MAXSPAMOUNT : VAR_MAXHPAMOUNT); + + // Now we need to randomly decide what will be .@opt1 and .@opt2 + // Would be better to not rely on rand here, though. + .@opt1=any(.@bonus, .@magic); + .@opt2=any(.@buffs, .@heals); + + // Apply the bonuses. They're capped by equip level and based on: + // Equip level, crafting experience and crafting skill + .@val=min(.@lv, (.@skill*CRAFTING_SCORE)/100+.@skill); + + // MDEF rule range is 99 while DEF rule range is 399 + // This is a really hackish way, for the record + if (.@opt1 == VAR_MDEFPOWER) + .@val=.@val/4; + + // First option will always succeed + .@val1=rand2(.@val); + setitemoptionbyindex(.@index, 0, .@opt1, .@val1); + + // Lucky roll (5% per skill level, capped at 50%) + // The lucky roll will add the extra attributes + if (rand2(20) < .@skill) { + .@val2=rand2(.@val); + setitemoptionbyindex(.@index, 1, .@opt2, .@val2); + } + + // Get experience for the craft + // I'm using the same EXP formula from Moubootaur Legends + // Which is based on the item sell price + .@xp=getiteminfo(.@it, ITEMINFO_SELLPRICE); + getexp .@xp+BaseLevel, (.@xp/3)+BaseLevel+JobLevel; + .success=true; + } else { + .success=false; + } + } + deletecraft .@craft; + setskin ""; + return .success; +} + + diff --git a/npc/functions/main.txt b/npc/functions/main.txt index 9618e47e..e4c4cd88 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -269,3 +269,22 @@ function script get_race { return .@allskins$[.@g] + " " + .@allraces$[.@g]; } +// Clear output of getinventorylist() +// delinventorylist() +function script delinventorylist { + deletearray @inventorylist_id; + deletearray @inventorylist_amount; + deletearray @inventorylist_equip; + deletearray @inventorylist_refine; + deletearray @inventorylist_identify; + deletearray @inventorylist_attribute; + deletearray @inventorylist_card1; + deletearray @inventorylist_card2; + deletearray @inventorylist_card3; + deletearray @inventorylist_card4; + deletearray @inventorylist_expire; + deletearray @inventorylist_bound; + @inventorylist_count=0; + return; +} + diff --git a/npc/functions/quest-debug/055-General_Cooking.txt b/npc/functions/quest-debug/055-General_Cooking.txt index ed9fb685..76e23b17 100644 --- a/npc/functions/quest-debug/055-General_Cooking.txt +++ b/npc/functions/quest-debug/055-General_Cooking.txt @@ -10,7 +10,7 @@ function script QuestDebug55 { mes "General_Cooking"; mes "---"; mes l("Quest state: @@", getq(General_Cooking)); - mes l("Known Recipes: @@", array_entries(COOKING_RECIPES)); + mes l("Known Recipes: @@", array_entries(RECIPES)); next; select @@ -33,14 +33,14 @@ function script QuestDebug55 { getitem RecipeBook, 1; break; case 5: - COOKING_RECIPES[CraftCarpSandwich]=true; - COOKING_RECIPES[CraftMananaSandwich]=true; - COOKING_RECIPES[CraftPioulegSandwich]=true; + RECIPES[CraftCarpSandwich]=true; + RECIPES[CraftMananaSandwich]=true; + RECIPES[CraftPioulegSandwich]=true; break; case 6: - COOKING_RECIPES[CraftCarpSandwich]=false; - COOKING_RECIPES[CraftMananaSandwich]=false; - COOKING_RECIPES[CraftPioulegSandwich]=false; + RECIPES[CraftCarpSandwich]=false; + RECIPES[CraftMananaSandwich]=false; + RECIPES[CraftPioulegSandwich]=false; break; } |