@@ -2,6 +2,7 @@ use cfgfile;
22use uo;
33use os;
44use util;
5+
56include "include/client";
67include ":attributes:attributes";
78include "include/string";
@@ -13,10 +14,11 @@ include "include/noto";
1314include "include/crafting";
1415include ":gumps:requestGump";
1516
17+ var bowcraftconfigfile := ReadConfigFile("bowcraft");
1618
1719program use_blade(who, blade)
1820 var craftingbag := FindCraftingbag (who);
19-
21+
2022 EraseObjProperty(who, "IsMeditating");
2123 EraseObjProperty(who, "HealTimer");
2224 if(!can_access(who, blade))
@@ -36,7 +38,9 @@ program use_blade(who, blade)
3638 endif
3739 endif
3840 var checkme := use_on.item.objtype;
39- if (use_on.mobile.graphic == CID_SHEERED_SHEEP)
41+ if((checkme == 0x1BDD) || (checkme == 0x1bd7))
42+ CarveLogs( who, blade, use_on.item );
43+ elseif (use_on.mobile.graphic == CID_SHEERED_SHEEP)
4044 SendSysMessage(who, "You cannot get any more wool from that sheep", color := 33);
4145 return 0;
4246 elseif (use_on.mobile.graphic == CID_SHEEP)
@@ -277,4 +281,110 @@ function make_jack_o_latern(who, blade, pumpkin)
277281 SendSysMessage(who,"That ain't no pumpkin.");
278282 endif
279283 endfunction
280-
284+
285+ function CarveLogs(who, blade, logs)
286+ if(logs.movable == 0)
287+ SendSysMessage(who, "You cannot use those logs.");
288+ return;
289+ endif
290+ if((!Accessible(who, logs)) or (!CheckLineOfSight(who, logs)) or (dist(who, logs) > 2))
291+ SendSysMessage(who, "You cannot use that");
292+ return;
293+ endif
294+ if(!logs.container)
295+ if(Distance(who, logs) > 2)
296+ SendSysMessage(who, "That is too far away");
297+ return;
298+ endif
299+ endif
300+ var creatable := CreatableObjects(who, blade, logs);
301+ var selection := SelectMenuItem2(who, "BowcraftCarving");
302+ if(!selection)
303+ return;
304+ endif
305+ var what := selection.objtype;
306+ if(!Accessible(who, logs))
307+ SendSysMessage(who, "I can't access the logs to make that.");
308+ return;
309+ endif
310+ var objectconfig := FindConfigElem(bowcraftconfigfile, what);
311+ if(!objectconfig)
312+ return;
313+ endif
314+ var material := CInt(GetConfigString(objectconfig, "Material"));
315+ if(material > logs.amount)
316+ SendSysMessage(who, "You don't have enough logs to make that.");
317+ return;
318+ endif
319+ var difficulty := GetConfigInt(objectconfig, "Difficulty");
320+ var pointvalue := GetConfigInt(objectconfig, "PointValue");
321+ var bow := 0;
322+ Detach();
323+ PlaySoundEffect(who, 0x5a);
324+ PerformAction(who, 0x021);
325+ sleep(2);
326+ PlaySoundEffect(who, 0x5a);
327+ PerformAction(who, 0x021);
328+ sleep(2);
329+ PlaySoundEffect(who, 0x5a);
330+ PerformAction(who, 0x021);
331+ sleep(2);
332+ PlaySoundEffect(who, 0x5a);
333+ PerformAction(who, 0x021);
334+ sleep(2);
335+ if(SkillCheck(who, BOWCRAFT, difficulty, pointvalue))
336+ if(what == UOBJ_SHAFTS)
337+ var amt := logs.amount;
338+ if(DestroyItem(logs))
339+ CreateItemInBackpack(who, what, amt);
340+ CheckToolWear (who, blade, BOWCRAFT);
341+ SendSysMessage(who, "You create some shafts and place them in your pack." );
342+ endif
343+ elseif (what == UOBJ_BOW)
344+ if(SubtractAmount(logs, material))
345+ bow := CreateItemInBackpack(who, what);
346+ CheckToolWear (who, blade, BOWCRAFT);
347+ SendSysMessage(who, "You create a bow and place it in your pack.");
348+ SetName(bow, "a bow");
349+ endif
350+ elseif (what == UOBJ_XBOW)
351+ if(SubtractAmount(logs, material))
352+ bow := CreateItemInBackpack(who, what);
353+ CheckToolWear (who, blade, BOWCRAFT);
354+ SendSysMessage(who, "You create a crossbow and place it in your pack.");
355+ SetName(bow, "a crossbow");
356+ endif
357+ elseif (what == UOBJ_HEAVY_XBOW)
358+ if(SubtractAmount(logs, material))
359+ bow := CreateItemInBackpack(who, what);
360+ CheckToolWear (who, blade, BOWCRAFT);
361+ SendSysMessage(who, "You create a heavy crossbow and place it in your pack.");
362+ SetName(bow, "a heavy crossbow");
363+ endif
364+ else
365+ SendSysMessage(who, "I don't know how to make that.");
366+ return;
367+ endif
368+ if((RandomInt(CInt(GetEffectiveSkill(who,SKILLID_BOWCRAFT)) + 1) > (difficulty + 20)) && (bow != 0))
369+ setquality(who, bow);
370+ // var skill := GetEffectiveSkill(who, SKILLID_BOWCRAFT);
371+ // ExceptionalFameMod(who, skill, difficulty, pointvalue);
372+ endif
373+ else
374+ SubtractAmount(logs, (RandomInt(5) + 1));
375+ SendSysMessage(who, "You destroy some logs.");
376+ endif
377+ endfunction
378+
379+ function setquality(who, bow)
380+ var tname := TruncateArticle(bow.name);
381+ if(CInt(AP_GetSkill(who, BOWCRAFT)) >= 99)
382+ bow.name := "an exceptional " + tname + " [crafted by " + who.name + "]";
383+ else
384+ bow.name := "an exceptional " + tname;
385+ endif
386+ bow.quality := bow.quality + 0.2;
387+ bow.hp := bow.maxhp;
388+ SendSysMessage(who, "You created an exceptional item.");
389+ endfunction
390+
0 commit comments