Guest User

Untitled

a guest
Jan 5th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.35 KB | None | 0 0
  1. use cfgfile;
  2. use uo;
  3. use os;
  4. use util;
  5. include "include/client";
  6. include "include/attributes";
  7. include "include/string";
  8. include "include/objtype";
  9. include "include/canAccess";
  10. include "include/dist";
  11. include "include/toolWear";
  12. include "include/noto";
  13.  
  14. var bowcraftconfigfile := ReadConfigFile("bowcraft");
  15.  
  16. program use_blade(who, blade)
  17. EraseObjProperty(who, "IsMeditating");
  18. EraseObjProperty(who, "HealTimer");
  19. if(!can_access(who, blade))
  20. return;
  21. endif
  22. if(!ReserveItem(blade))
  23. return;
  24. endif
  25. SendSysMessage(who, "What would you like to use that on, " + who.name + "?");
  26. var use_on := TargetCoordinates(who);
  27. if(!use_on)
  28. return;
  29. endif
  30. if(use_on.item)
  31. if(!can_access(who, use_on.item, "unmovable"))
  32. return;
  33. endif
  34. endif
  35. var checkme := use_on.item.objtype;
  36. if((checkme == UOBJ_LOGS) || (checkme == 0x1bd7))
  37. CarveLogs( who, blade, use_on.item );
  38. elseif(use_on.mobile.npctemplate == "sheep")
  39. process_wool(who, blade, use_on.mobile);
  40. elseif(use_on.item.objtype == UOBJ_CORPSE)
  41. ReleaseItem(blade);
  42. Carve_Corpse(who, use_on.item);
  43. elseif(is_fish(checkme))
  44. CarveFish(who, blade, use_on.item);
  45. elseif (is_tree(use_on.objtype ))
  46. CarveTree(who, blade, use_on.item);
  47. elseif (is_seashell(checkme)) // ADDED BY SIGMUND
  48. ExtractPearls(who, blade, use_on.item);
  49. else
  50. SendSysMessage(who, "I don't know how to use those items together.");
  51. endif
  52. endprogram
  53.  
  54. function process_wool(who, blade, sheep)
  55. if((!CheckLineOfSight(who, sheep)) or (dist(who, sheep) > 2))
  56. SendSysMessage(who, "You cannot use that");
  57. return;
  58. endif
  59. if(sheep.graphic == 207)
  60. sheep.graphic := 223;
  61. CreateItemInContainer(who.backpack, 0xf125, 3);
  62. else
  63. SendSysMessage(who,"That sheep is not yet ready to be shorn.");
  64. endif
  65. endfunction
  66.  
  67. function is_tree(theobj)
  68. if((theobj == 0x0c9e) || (theobj == 0x0ca8) || (theobj == 0x0caa))
  69. return 1;
  70. elseif (theobj == 0x0cab)
  71. return 1;
  72. elseif ((theobj >= 0x0c99) && (theobj <= 0x0cea))
  73. return 1;
  74. elseif ((theobj >= 0x0cf3) && (theobj <= 0x0d03))
  75. return 1;
  76. elseif ((theobj >= 0x0d41) && (theobj <= 0x0dab))
  77. return 1;
  78. else
  79. return 0;
  80. endif
  81. endfunction
  82.  
  83. function is_fish(theobj)
  84. if((theobj >= UOBJ_FISH_START) && (theobj <= UOBJ_FISH_END) )
  85. return 1;
  86. elseif ((theobj >= UOBJ_SFISH_START) && (theobj <= UOBJ_SFISH_END))
  87. return 1;
  88. else
  89. return 0;
  90. endif
  91. endfunction
  92.  
  93. function is_seashell(theobj)
  94. // Checks if the objtype is a seashell
  95. if ((theobj >=0x0fc4) && (theobj <=0x0fcc))
  96. return 1;
  97. else
  98. return 0;
  99. endif
  100. endfunction
  101.  
  102. function CarveTree(who, blade, use_on)
  103. if(dist(who, use_on) > 2)
  104. SendSysMessage(who, "You cannot use that");
  105. return;
  106. endif
  107. CreateItemInBackpack(who, UOBJ_KINDLING, 1);
  108. DestroyItem(use_on);
  109. SendSysMessage(who, "You chip off some kindling and put it in your backpack");
  110. endfunction
  111.  
  112. function CarveFish(who, blade, use_on)
  113. if((!Accessible(who, use_on)) or (!CheckLineOfSight(who, use_on)) or (dist(who, use_on) > 2))
  114. SendSysMessage(who, "You cannot use that");
  115. return;
  116. endif
  117. if((!ReserveItem(use_on)) || (use_on.movable == 0))
  118. SendSysMessage(who, "You cannot use that.");
  119. return;
  120. endif
  121. var num_steaks := (4 * use_on.amount);
  122. PlaySoundEffect(who, SFX_57);
  123. if(DestroyItem(use_on))
  124. CreateItemInBackpack(who, UOBJ_FISHSTEAK, num_steaks);
  125. SendSysMessage(who, "You carve the fish steaks and put them in your backpack");
  126. endif
  127. sleep(1);
  128. endfunction
  129.  
  130. function CreatableObjects( who, blade, logs )
  131. var objtypes := GetMenuObjTypes( "BowcraftCarving" );
  132. objtypes := ApplyConstraint( objtypes, bowcraftconfigfile, "material", GetAmount(logs) );
  133. return objtypes;
  134. endfunction
  135.  
  136. function Carve_Corpse(who, cadaver)
  137. Detach();
  138. if((!Accessible(who, cadaver)) or (!CheckLineOfSight(who, cadaver)))
  139. SendSysMessage(who, "You cannot use that");
  140. return;
  141. endif
  142. if(Distance(who, cadaver) > 2)
  143. SendSysMessage(who, "You are not close enough");
  144. return;
  145. endif
  146. var c_type := cadaver.corpsetype;
  147. if(GetObjProperty(cadaver, "cut") == "1")
  148. SendSysMessage( who, "You cannot get any more from this corpse." );
  149. foreach thing in EnumerateItemsInContainer(cadaver)
  150. MoveItemToLocation(thing, cadaver.x, cadaver.y, cadaver.z, MOVEITEM_FORCELOCATION);
  151. endforeach
  152. DestroyItem(cadaver);
  153. elseif((c_type == 400) || (c_type == 401))
  154. var beardlist := {0x203e, 0x203f, 0x2040, 0x2041, 0x204b, 0x204c, 0x204d };
  155. var hairlist := {0x2044, 0x2045, 0x2046, 0x2047, 0x2048, 0x2049, 0x204a, 0x203b, 0x203c, 0x203d };
  156. foreach thing in EnumerateItemsInContainer(cadaver)
  157. if((thing.objtype in hairlist) or (thing.objtype in beardlist))
  158. DestroyItem(thing);
  159. else
  160. MoveItemToLocation(thing, cadaver.x, cadaver.y, cadaver.z, MOVEITEM_FORCELOCATION);
  161. endif
  162. endforeach
  163. var partsarray := {};
  164. var part;
  165. part := CreateItemAtLocation(cadaver.x-1, cadaver.y, cadaver.z, 0x1da0, 1);
  166. partsarray.append(part);
  167. SetObjProperty(part, "serial", GetObjProperty(cadaver, "serial"));
  168. var aname := cadaver.name;
  169. aname["A corpse of"] := "";
  170. part.name := "The head of " + aname;
  171. part := CreateItemAtLocation(cadaver.x-1, cadaver.y, cadaver.z, 0x1da1, 1);
  172. partsarray.append(part);
  173. part := CreateItemAtLocation(cadaver.x-1, cadaver.y+1, cadaver.z, 0x1da2, 1);
  174. partsarray.append(part);
  175. part := CreateItemAtLocation(cadaver.x+1, cadaver.y, cadaver.z, 0x1da3, 1);
  176. partsarray.append(part);
  177. part := CreateItemAtLocation(cadaver.x+1, cadaver.y+1, cadaver.z, 0x1da4, 1);
  178. partsarray.append(part);
  179. part := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, 0x1d9f, 1);
  180. partsarray.append(part);
  181. var blood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, 0x122a, 1);
  182. blood.movable := 0;
  183. DestroyItem(cadaver);
  184. sleep(40);
  185. foreach thing in partsarray
  186. if(!thing.container)
  187. DestroyItem(thing);
  188. endif
  189. endforeach
  190. sleep(20);
  191. DestroyItem(blood);
  192. else
  193. if(c_type == 223)
  194. CreateItemInContainer(cadaver, 0x9f1, 2);
  195. SendSysMessage(who, "You place the items on the corpse.");
  196. var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
  197. sleep(30);
  198. DestroyItem(cadaver);
  199. sleep(30);
  200. DestroyItem(theblood);
  201. return;
  202. endif
  203. var conf := ReadConfigFile(":*:npcdesc");
  204. var tmplate := GetObjProperty(cadaver, "npctemplate");
  205. if(!tmplate)
  206. SendSysMessage(who, "You cut the corpse, but fail to find anything useful.", 3, 40);
  207. var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
  208. sleep(30);
  209. DestroyItem(cadaver);
  210. sleep(30);
  211. DestroyItem(theblood);
  212. return;
  213. else
  214. SetObjProperty(cadaver, "cut","1");
  215. var corpseitm := conf[tmplate]."corpseitm";
  216. var corpseamt := conf[tmplate]."corpseamt";
  217. print("I: " + corpseitm);
  218. print("A: " + corpseamt);
  219. if(!corpseitm)
  220. print("error");
  221. var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
  222. sleep(30);
  223. DestroyItem(cadaver);
  224. sleep(30);
  225. DestroyItem(theblood);
  226. return;
  227. endif
  228. var i := 1;
  229. corpseitm := SplitWords(corpseitm);
  230. corpseamt := SplitWords(corpseamt);
  231. foreach thing in corpseitm
  232. CreateItemInContainer(cadaver, thing, Cint(corpseamt[i]));
  233. i := i + 1;
  234. endforeach
  235. SendSysMessage(who, "You place the items on the corpse.");
  236. var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
  237. sleep(30);
  238. DestroyItem(cadaver);
  239. sleep(30);
  240. DestroyItem(theblood);
  241. endif
  242. endif
  243. endfunction
  244.  
  245. function CarveLogs(who, blade, logs)
  246. if(logs.movable == 0)
  247. SendSysMessage(who, "You cannot use those logs.");
  248. return;
  249. endif
  250. if((!Accessible(who, logs)) or (!CheckLineOfSight(who, logs)) or (dist(who, logs) > 2))
  251. SendSysMessage(who, "You cannot use that");
  252. return;
  253. endif
  254. if(!logs.container)
  255. if(Distance(who, logs) > 2)
  256. SendSysMessage(who, "That is too far away");
  257. return;
  258. endif
  259. endif
  260. var creatable := CreatableObjects(who, blade, logs);
  261. var selection := SelectMenuItem2(who, "BowcraftCarving");
  262. if(!selection)
  263. return;
  264. endif
  265. var what := selection.objtype;
  266. if(!Accessible(who, logs))
  267. SendSysMessage(who, "I can't access the logs to make that.");
  268. return;
  269. endif
  270. var objectconfig := FindConfigElem(bowcraftconfigfile, what);
  271. if(!objectconfig)
  272. return;
  273. endif
  274. var material := CInt(GetConfigString(objectconfig, "Material"));
  275. if(material > logs.amount)
  276. SendSysMessage(who, "You don't have enough logs to make that.");
  277. return;
  278. endif
  279. var difficulty := GetConfigInt(objectconfig, "Difficulty");
  280. var pointvalue := GetConfigInt(objectconfig, "PointValue");
  281. var bow := 0;
  282. Detach();
  283. PlaySoundEffect(who, 0x5a);
  284. PerformAction(who, 0x021);
  285. sleep(2);
  286. PlaySoundEffect(who, 0x5a);
  287. PerformAction(who, 0x021);
  288. sleep(2);
  289. PlaySoundEffect(who, 0x5a);
  290. PerformAction(who, 0x021);
  291. sleep(2);
  292. PlaySoundEffect(who, 0x5a);
  293. PerformAction(who, 0x021);
  294. sleep(2);
  295. if(CheckSkill(who, SKILLID_BOWCRAFT, difficulty, pointvalue))
  296. if(what == UOBJ_SHAFTS)
  297. var amt := logs.amount;
  298. if(DestroyItem(logs))
  299. CreateItemInBackpack(who, what, amt);
  300. CheckToolWear (who, blade, SKILLID_BOWCRAFT);
  301. SendSysMessage(who, "You create some shafts and place them in your pack." );
  302. endif
  303. elseif (what == UOBJ_BOW)
  304. if(SubtractAmount(logs, material))
  305. bow := CreateItemInBackpack(who, what);
  306. CheckToolWear (who, blade, SKILLID_BOWCRAFT);
  307. SendSysMessage(who, "You create a bow and place it in your pack.");
  308. SetName(bow, "a bow");
  309. endif
  310. elseif (what == UOBJ_XBOW)
  311. if(SubtractAmount(logs, material))
  312. bow := CreateItemInBackpack(who, what);
  313. CheckToolWear (who, blade, SKILLID_BOWCRAFT);
  314. SendSysMessage(who, "You create a crossbow and place it in your pack.");
  315. SetName(bow, "a crossbow");
  316. endif
  317. elseif (what == UOBJ_HEAVY_XBOW)
  318. if(SubtractAmount(logs, material))
  319. bow := CreateItemInBackpack(who, what);
  320. CheckToolWear (who, blade, SKILLID_BOWCRAFT);
  321. SendSysMessage(who, "You create a heavy crossbow and place it in your pack.");
  322. SetName(bow, "a heavy crossbow");
  323. endif
  324. else
  325. SendSysMessage(who, "I don't know how to make that.");
  326. return;
  327. endif
  328. if((RandomInt(CInt(GetEffectiveSkill(who,SKILLID_BOWCRAFT)) + 1) > (difficulty + 20)) && (bow != 0))
  329. setquality(who, bow);
  330. // var skill := GetEffectiveSkill(who, SKILLID_BOWCRAFT);
  331. // ExceptionalFameMod(who, skill, difficulty, pointvalue);
  332. endif
  333. else
  334. SubtractAmount(logs, (RandomInt(5) + 1));
  335. SendSysMessage(who, "You destroy some logs.");
  336. endif
  337. endfunction
  338.  
  339. function ExtractPearls(who, blade, seashell)
  340. // STILL NEED TO ADD A CHECK FOR BLADE OBJTYPES
  341. // SO YOU CAN ONLY USE KNIVES TO EXTRACT
  342. var skill := GetEffectiveSkill(who, SKILLID_FISHING);
  343.  
  344. if((!Accessible(who, seashell)) or (!CheckLineOfSight(who,seashell)))
  345. SendSysMessage(who, "You cannot use that");
  346. return;
  347. endif
  348. if(Distance(who, seashell) > 2)
  349. SendSysMessage(who, "You are not close enough");
  350. return;
  351. endif
  352. if(skill < 50.0)
  353. SendSysMessage(who, "You don't know how to do that.");
  354. return;
  355. endif
  356.  
  357. SendSysMessage(who, "Extracting pearls...");
  358. PlaySoundEffect(who, 0x5a);
  359. PerformAction(who, 0x021);
  360. sleep(2);
  361. SendSysMessage(who, "Extracting pearls...");
  362. PlaySoundEffect(who, 0x5a);
  363. PerformAction(who, 0x021);
  364. sleep(2);
  365. SendSysMessage(who, "Extracting pearls...");
  366. PlaySoundEffect(who, 0x5a);
  367. PerformAction(who, 0x021);
  368. sleep(2);
  369. if(Distance(who, seashell) > 2) //IF PLAYER MOVED MORE THAN 2 TILES FROM BEGINNING OF EXTRACTION STOP THE SCRIPT
  370. SendSysMessage(who, "You are not close enough");
  371. return;
  372. endif
  373.  
  374. var randomness;
  375. if(skill >= 50.0 && skill <= 59.9)
  376. randomness := RandomInt(30);
  377. if (randomness != 1)
  378. givePearls(who, 2, seashell);
  379. else
  380. SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
  381. return;
  382. endif
  383. elseif(skill >= 60.0 && skill <= 79.9)
  384. randomness := RandomInt(20) + 1;
  385. if (randomness != 1)
  386. givePearls(who, 4, seashell);
  387. else
  388. SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
  389. return;
  390. endif
  391. elseif(skill >= 80.0 && skill <= 99.9)
  392. randomness := RandomInt(10);
  393. if (randomness != 1)
  394. givePearls(who, 6, seashell);
  395. else
  396. SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
  397. return;
  398. endif
  399. elseif(skill >= 100.0)
  400. randomness := RandomInt(1000);
  401. if (randomness != 1)
  402. givePearls(who, 10, seashell);
  403. else
  404. SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
  405. return;
  406. endif
  407. endif
  408.  
  409.  
  410. endfunction
  411.  
  412. function givePearls(who, how_many, shell)
  413. CreateItemInBackpack( who, 3962, how_many );
  414. SendSysMessage(who, "You successfully harvested "+how_many+" black pearls");
  415. DestroyItem(shell);
  416. endfunction
  417.  
  418. function ExceptionalFameMod(who, skill, diff, points)
  419. if(skill > (diff - 20))
  420. if((skill - diff) <= 5)
  421. points := points;
  422. elseif((skill - diff) <= 10)
  423. points := (points * 3) / 4;
  424. elseif((skill - diff) <= 15)
  425. points := points / 2;
  426. elseif((skill - diff) <= 20)
  427. points := points / 4;
  428. else
  429. points := 0;
  430. endif
  431. points := Cint(points);
  432. var fame := Cint(GetObjProperty(who, "Fame"));
  433. var famegain := fame + points;
  434. SetObjProperty(who, "Fame", famegain);
  435. var msgtext := "You have ";
  436. if(points < 0)
  437. msgtext := msgtext + "lost ";
  438. points := Abs(points);
  439. else
  440. msgtext := msgtext + "gained ";
  441. endif
  442. if(points > 150)
  443. msgtext := msgtext + "a great amount of ";
  444. elseif(points > 125)
  445. msgtext := msgtext + "alot of ";
  446. elseif(points > 75)
  447. msgtext := msgtext + "a good amount of ";
  448. elseif(points > 30)
  449. msgtext := msgtext + "some ";
  450. elseif(points > 0)
  451. msgtext := msgtext + "a little ";
  452. else
  453. return 0;
  454. endif
  455. msgtext := msgtext + "Fame.";
  456. SendSysMessage(who, msgtext);
  457. var karma := Cint(GetObjProperty(who, "Karma"));
  458. var kmod := GetKarmaLevel(karma);
  459. var fmod := GetFameLevel(famegain);
  460. var newtitle := nototitles[ (kmod) ];
  461. newtitle := "The " + CStr(newtitle[fmod]) + " ";
  462. if(newtitle["None"])
  463. newtitle := "";
  464. endif
  465. if(fmod == 5)
  466. if(who.gender == 1)
  467. newtitle := newtitle + "Lady ";
  468. else
  469. newtitle := newtitle + "Lord ";
  470. endif
  471. endif
  472. if(newtitle != who.title_prefix)
  473. who.title_prefix := newtitle;
  474. SendSysMessage(who, "you are now known as " + newtitle + who.name);
  475. endif
  476. SetNotoTitle(who, karma, fame);
  477. endif
  478. endfunction
  479.  
  480. function setquality(who, bow)
  481. var tname := TruncateArticle(bow.name);
  482. if(CInt(GetEffectiveSkill(who, SKILLID_BOWCRAFT)) >= 99)
  483. bow.name := "an exceptional " + tname + " [crafted by " + who.name + "]";
  484. else
  485. bow.name := "an exceptional " + tname;
  486. endif
  487. bow.quality := bow.quality + 0.2;
  488. bow.hp := bow.maxhp;
  489. SendSysMessage(who, "You created an exceptional item.");
  490. endfunction
Add Comment
Please, Sign In to add comment