summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/025-1/_import.txt1
-rw-r--r--npc/025-1/ihclot.txt136
-rw-r--r--npc/craft/options.txt60
3 files changed, 197 insertions, 0 deletions
diff --git a/npc/025-1/_import.txt b/npc/025-1/_import.txt
index b534e2772..8077fd8b5 100644
--- a/npc/025-1/_import.txt
+++ b/npc/025-1/_import.txt
@@ -3,4 +3,5 @@
"npc/025-1/_config.txt",
"npc/025-1/_mobs.txt",
"npc/025-1/ctrl.c",
+"npc/025-1/ihclot.txt",
"npc/025-1/salohcin.txt",
diff --git a/npc/025-1/ihclot.txt b/npc/025-1/ihclot.txt
new file mode 100644
index 000000000..d4f260d67
--- /dev/null
+++ b/npc/025-1/ihclot.txt
@@ -0,0 +1,136 @@
+// TMW2 scripts.
+// Author:
+// Jesusalva
+// Description:
+// Ihclot is Tolchi spelled backwards
+
+025-1,96,66,0 script Ihclot NPC_RAIJIN_FEMALE_LEGION_ARTIS,{
+ function apRefresh;
+ function getPrice;
+ function getPriceInt;
+
+ apRefresh();
+ mesn;
+ mesq l("I put options on items upon request, but I am very expensive! This is deducted from your tweaking quota.");
+ if (!.@left) {
+ mesc l("You currently have no Tweaking AP, so you will need to wait %02d minute(s).", 60-gettime(GETTIME_MINUTE)), 1;
+ close;
+ }
+ next;
+ mesn;
+ mesq l("I'll read the options from you, but the level will be paid by me, and failure rate is non-existant. I am the best. blacksmith. in. the. universe! Use %s if you need to change any options.", b("@ucp"));
+ csysGUI_Report();
+
+ mesc l("Please select the item you plan in tweaking."), 1;
+ // Request and confirm
+ .@id=requestitemindex();
+ if (!csys_Confirm(.@id))
+ return false;
+
+ // Find numeric ID
+ delinventorylist();
+ getinventorylist();
+ .@handle=@inventorylist_id[.@id];
+ .@lv=getiteminfo(.@handle, ITEMINFO_ELV);
+
+ // Invalid (absolutely should never happen)
+ if (.@handle < 1) {
+ mesn;
+ mesq l("...What? Which item? Sorry, too much smoke around here.");
+ next;
+ return;
+ }
+ // Multiple
+ if (countitem(.@handle) != 1) {
+ mesn;
+ mesq l("Sorry, but you have multiple %s.", getitemlink(.@handle));
+ next;
+ return;
+ }
+ // Permission NG: (Not Granted)
+ if (.@lv < .minLevel) {
+ mesn;
+ mesq l("Sorry, but I won't dare touch a %s.", getitemlink(.@handle));
+ next;
+ mesn;
+ mesq l("Depending on the case, Nicholas, in Hurnscald, can do a better job than me.");
+ tutmes l("The selected item is too weak. %s will only tweak items level %d or higher.", .name$, .minLevel);
+ next;
+ return;
+ }
+ // Aleady slotted
+ if (getitemoptionidbyindex(.@id, 0) > 0) {
+ mesn;
+ mesq l("I'm not going to try to improve this masterpiece. Look its options!");
+ next;
+ return;
+ }
+
+ // Calculate price
+ .@price=.@lv**3; // Cubic function to determine price.
+ mesn;
+ mesq l("Please select the level I should use.");
+ menuint
+ l("Abort (%d GP)", fnum(.@price*0)), 0,
+ getPrice(.@price, 10), 10,
+ getPrice(.@price, 20), 20,
+ getPrice(.@price, 30), 30,
+ getPrice(.@price, 40), 40,
+ getPrice(.@price, 50), 50,
+ getPrice(.@price, 60), 60,
+ getPrice(.@price, 70), 70,
+ getPrice(.@price, 80), 80,
+ getPrice(.@price, 90), 90,
+ getPrice(.@price, 100), 100;
+ mes "";
+ if (@menuret == 0)
+ close;
+
+ // Ask player to confirm
+ if (!csys_Confirm(.@id))
+ return false;
+
+ // Perform payment
+ Zeny-=getPriceInt(.@price, @menuret);
+ SMITH_TWEAKS+=1;
+
+ // Apply the bonuses
+ csys_ApplyPerfect(.@id, .@level);
+ mesn;
+ mesc l("Well, here you are. I hope you enjoy ^^", 3);
+ close;
+
+/* *************************************************************************** */
+function apRefresh {
+ .@left=gettimeparam(GETTIME_HOUR)-SMITH_TWEAKS;
+ if (.@left > 6) {
+ .@left=6;
+ SMITH_TWEAKS=gettimeparam(GETTIME_HOUR)-6;
+ }
+ return;
+}
+
+function getPriceInt {
+ .@price=getarg(0);
+ .@level=getarg(1);
+ return .@price*.@level/3;
+}
+
+function getPrice {
+ .@price=getarg(0);
+ .@level=getarg(1);
+ .@final=getPriceInt(.@price, .@level);
+ if (Zeny >= .@final)
+ return l("Level %d (%d GP)", .@level, fnum(.@final));
+ else
+ return "";
+}
+
+OnInit:
+ .sex = G_OTHER;
+ .distance = 5;
+ .minLevel = 50;
+ end;
+}
+
+
diff --git a/npc/craft/options.txt b/npc/craft/options.txt
index 3928adff1..b023a1e19 100644
--- a/npc/craft/options.txt
+++ b/npc/craft/options.txt
@@ -636,6 +636,66 @@ function script csys_Apply {
return;
}
+// Attribute perfect item options
+// For Fortress Island only
+// csys_ApplyPerfect( invindex, lvl{, scope} )
+function script csys_ApplyPerfect {
+ .@id=getarg(0);
+ .@lv=getarg(1);
+ .@sc=getarg(2, CRAFTSYS_CURRENT);
+
+ // Generate lists, disregarding level
+ csys_Generate(.@sc);
+ // @csys_attr → Available attributes
+ // @csys_penalty → Penalty attribute array
+
+ // Remove weapon-only bonuses if it is armor
+ delinventorylist();
+ getinventorylist();
+ .@itemid=@inventorylist_id[.@id];
+ if (getiteminfo(.@itemid, ITEMINFO_TYPE) != IT_WEAPON)
+ csys_ArmorFix(.@itemid);
+ else
+ csys_WeaponFix(.@itemid);
+ .@eqplv=getiteminfo(.@itemid, ITEMINFO_ELV);
+
+ // Shuffle the arrays
+ array_shuffle(@csys_attr);
+ array_shuffle(@csys_penalty);
+
+ // How many bonuses we'll have? Never more than 3 bonus and 2 onus.
+ .@max_attr=getarraysize(@csys_attr);
+ .@max_pena=getarraysize(@csys_penalty);
+
+ if ($@GM_OVERRIDE)
+ debugmes "ApplyPerfect: We have %d attributes and %d penalties",
+ .@max_attr, .@max_pena;
+
+ .@slot=0;
+ while (.@slot < min(3, .@max_attr)) {
+ // Apply a bonus using array_pop (it was shuffled so we're fine)
+ .@vartp=array_pop(@csys_attr);
+ .@bonus=csys_BonusCalc(10, .@lv, .@vartp, .@eqplv);
+ setitemoptionbyindex(.@id, .@slot, .@vartp, .@bonus);
+ //debugmes "Bonus applied: %d at %d (slot: %d)", .@vartp, .@bonus, .@slot;
+ .@slot+=1;
+ }
+
+ if (.@max_pena) {
+ // Apply a malus using array_pop (it was shuffled so we're fine)
+ .@vartp=array_pop(@csys_penalty);
+ .@malus=csys_BonusCalc(10, .@lv, .@vartp);
+ .@malus=.@malus*70/100;
+ if (.@vartp > 0 && .@malus > 0)
+ setitemoptionbyindex(.@id, .@slot, .@vartp, -(.@malus));
+ .@slot+=1;
+ }
+
+ // The options have been attributed, clear temporary variables
+ @csysArmor=false;
+ return;
+}
+