summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-07-06 12:13:16 -0300
committerJesusaves <cpntb1@ymail.com>2020-07-06 12:13:16 -0300
commit34fafe8468493d52ce3b1fa08a88c524d230543e (patch)
treeb2783210a4fbabba5ccdc9a2b7e9376219901616
parent9637f2b2090d7a869937415a60c7f42c4e08ba29 (diff)
downloadserverdata-34fafe8468493d52ce3b1fa08a88c524d230543e.tar.gz
serverdata-34fafe8468493d52ce3b1fa08a88c524d230543e.tar.bz2
serverdata-34fafe8468493d52ce3b1fa08a88c524d230543e.tar.xz
serverdata-34fafe8468493d52ce3b1fa08a88c524d230543e.zip
Extend crafting framework
-rw-r--r--npc/functions/crafting.txt49
-rw-r--r--npc/functions/main.txt19
2 files changed, 54 insertions, 14 deletions
diff --git a/npc/functions/crafting.txt b/npc/functions/crafting.txt
index 796141a1..050851ec 100644
--- a/npc/functions/crafting.txt
+++ b/npc/functions/crafting.txt
@@ -30,29 +30,50 @@ function script SmithSystem {
getitem(.@it, 1);
.success=true;
} else if (RECIPES_EQUIPMENT[.@entry]) {
- // Player craft item
+ // 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+=getiteminfo(.@it, ITEMINFO_ELV);
+ CRAFTING_SCORE+=.@lv;
// Obtain the item, and record the craftsman name
// PS. This prevents dyes from being used!!
- getnameditem(.@it, strcharinfo(0));
+ //getnameditem(.@it, strcharinfo(0));
+ 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);
+ .@val1=rand2(.@val);
+ setitemoptionbyindex(.@index, 0, .@opt1, .@val1);
- // This is where we add options we don't want this now
- // The functions are not ready yet
- /*
- if (getskilllv(EVOL_CRAFTING)) {
- delinventorylist(); // Needed, because we'll rely on rfind()
- getinventorylist();
- .@index=array_rfind(@inventorylist_id, .@it);
- if (csys_Check(.@index, 75000)) {
- csys_Apply(.@index);
- }
+ // Lucky roll (5% per skill level, base of 1%)
+ // The lucky roll will add magic 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
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;
+}
+