Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use cfgfile;
- use uo;
- use os;
- use util;
- include "include/client";
- include "include/attributes";
- include "include/string";
- include "include/objtype";
- include "include/canAccess";
- include "include/dist";
- include "include/toolWear";
- include "include/noto";
- var bowcraftconfigfile := ReadConfigFile("bowcraft");
- program use_blade(who, blade)
- EraseObjProperty(who, "IsMeditating");
- EraseObjProperty(who, "HealTimer");
- if(!can_access(who, blade))
- return;
- endif
- if(!ReserveItem(blade))
- return;
- endif
- SendSysMessage(who, "What would you like to use that on, " + who.name + "?");
- var use_on := TargetCoordinates(who);
- if(!use_on)
- return;
- endif
- if(use_on.item)
- if(!can_access(who, use_on.item, "unmovable"))
- return;
- endif
- endif
- var checkme := use_on.item.objtype;
- if((checkme == UOBJ_LOGS) || (checkme == 0x1bd7))
- CarveLogs( who, blade, use_on.item );
- elseif(use_on.mobile.npctemplate == "sheep")
- process_wool(who, blade, use_on.mobile);
- elseif(use_on.item.objtype == UOBJ_CORPSE)
- ReleaseItem(blade);
- Carve_Corpse(who, use_on.item);
- elseif(is_fish(checkme))
- CarveFish(who, blade, use_on.item);
- elseif (is_tree(use_on.objtype ))
- CarveTree(who, blade, use_on.item);
- elseif (is_seashell(checkme)) // ADDED BY SIGMUND
- ExtractPearls(who, blade, use_on.item);
- else
- SendSysMessage(who, "I don't know how to use those items together.");
- endif
- endprogram
- function process_wool(who, blade, sheep)
- if((!CheckLineOfSight(who, sheep)) or (dist(who, sheep) > 2))
- SendSysMessage(who, "You cannot use that");
- return;
- endif
- if(sheep.graphic == 207)
- sheep.graphic := 223;
- CreateItemInContainer(who.backpack, 0xf125, 3);
- else
- SendSysMessage(who,"That sheep is not yet ready to be shorn.");
- endif
- endfunction
- function is_tree(theobj)
- if((theobj == 0x0c9e) || (theobj == 0x0ca8) || (theobj == 0x0caa))
- return 1;
- elseif (theobj == 0x0cab)
- return 1;
- elseif ((theobj >= 0x0c99) && (theobj <= 0x0cea))
- return 1;
- elseif ((theobj >= 0x0cf3) && (theobj <= 0x0d03))
- return 1;
- elseif ((theobj >= 0x0d41) && (theobj <= 0x0dab))
- return 1;
- else
- return 0;
- endif
- endfunction
- function is_fish(theobj)
- if((theobj >= UOBJ_FISH_START) && (theobj <= UOBJ_FISH_END) )
- return 1;
- elseif ((theobj >= UOBJ_SFISH_START) && (theobj <= UOBJ_SFISH_END))
- return 1;
- else
- return 0;
- endif
- endfunction
- function is_seashell(theobj)
- // Checks if the objtype is a seashell
- if ((theobj >=0x0fc4) && (theobj <=0x0fcc))
- return 1;
- else
- return 0;
- endif
- endfunction
- function CarveTree(who, blade, use_on)
- if(dist(who, use_on) > 2)
- SendSysMessage(who, "You cannot use that");
- return;
- endif
- CreateItemInBackpack(who, UOBJ_KINDLING, 1);
- DestroyItem(use_on);
- SendSysMessage(who, "You chip off some kindling and put it in your backpack");
- endfunction
- function CarveFish(who, blade, use_on)
- if((!Accessible(who, use_on)) or (!CheckLineOfSight(who, use_on)) or (dist(who, use_on) > 2))
- SendSysMessage(who, "You cannot use that");
- return;
- endif
- if((!ReserveItem(use_on)) || (use_on.movable == 0))
- SendSysMessage(who, "You cannot use that.");
- return;
- endif
- var num_steaks := (4 * use_on.amount);
- PlaySoundEffect(who, SFX_57);
- if(DestroyItem(use_on))
- CreateItemInBackpack(who, UOBJ_FISHSTEAK, num_steaks);
- SendSysMessage(who, "You carve the fish steaks and put them in your backpack");
- endif
- sleep(1);
- endfunction
- function CreatableObjects( who, blade, logs )
- var objtypes := GetMenuObjTypes( "BowcraftCarving" );
- objtypes := ApplyConstraint( objtypes, bowcraftconfigfile, "material", GetAmount(logs) );
- return objtypes;
- endfunction
- function Carve_Corpse(who, cadaver)
- Detach();
- if((!Accessible(who, cadaver)) or (!CheckLineOfSight(who, cadaver)))
- SendSysMessage(who, "You cannot use that");
- return;
- endif
- if(Distance(who, cadaver) > 2)
- SendSysMessage(who, "You are not close enough");
- return;
- endif
- var c_type := cadaver.corpsetype;
- if(GetObjProperty(cadaver, "cut") == "1")
- SendSysMessage( who, "You cannot get any more from this corpse." );
- foreach thing in EnumerateItemsInContainer(cadaver)
- MoveItemToLocation(thing, cadaver.x, cadaver.y, cadaver.z, MOVEITEM_FORCELOCATION);
- endforeach
- DestroyItem(cadaver);
- elseif((c_type == 400) || (c_type == 401))
- var beardlist := {0x203e, 0x203f, 0x2040, 0x2041, 0x204b, 0x204c, 0x204d };
- var hairlist := {0x2044, 0x2045, 0x2046, 0x2047, 0x2048, 0x2049, 0x204a, 0x203b, 0x203c, 0x203d };
- foreach thing in EnumerateItemsInContainer(cadaver)
- if((thing.objtype in hairlist) or (thing.objtype in beardlist))
- DestroyItem(thing);
- else
- MoveItemToLocation(thing, cadaver.x, cadaver.y, cadaver.z, MOVEITEM_FORCELOCATION);
- endif
- endforeach
- var partsarray := {};
- var part;
- part := CreateItemAtLocation(cadaver.x-1, cadaver.y, cadaver.z, 0x1da0, 1);
- partsarray.append(part);
- SetObjProperty(part, "serial", GetObjProperty(cadaver, "serial"));
- var aname := cadaver.name;
- aname["A corpse of"] := "";
- part.name := "The head of " + aname;
- part := CreateItemAtLocation(cadaver.x-1, cadaver.y, cadaver.z, 0x1da1, 1);
- partsarray.append(part);
- part := CreateItemAtLocation(cadaver.x-1, cadaver.y+1, cadaver.z, 0x1da2, 1);
- partsarray.append(part);
- part := CreateItemAtLocation(cadaver.x+1, cadaver.y, cadaver.z, 0x1da3, 1);
- partsarray.append(part);
- part := CreateItemAtLocation(cadaver.x+1, cadaver.y+1, cadaver.z, 0x1da4, 1);
- partsarray.append(part);
- part := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, 0x1d9f, 1);
- partsarray.append(part);
- var blood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, 0x122a, 1);
- blood.movable := 0;
- DestroyItem(cadaver);
- sleep(40);
- foreach thing in partsarray
- if(!thing.container)
- DestroyItem(thing);
- endif
- endforeach
- sleep(20);
- DestroyItem(blood);
- else
- if(c_type == 223)
- CreateItemInContainer(cadaver, 0x9f1, 2);
- SendSysMessage(who, "You place the items on the corpse.");
- var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
- sleep(30);
- DestroyItem(cadaver);
- sleep(30);
- DestroyItem(theblood);
- return;
- endif
- var conf := ReadConfigFile(":*:npcdesc");
- var tmplate := GetObjProperty(cadaver, "npctemplate");
- if(!tmplate)
- SendSysMessage(who, "You cut the corpse, but fail to find anything useful.", 3, 40);
- var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
- sleep(30);
- DestroyItem(cadaver);
- sleep(30);
- DestroyItem(theblood);
- return;
- else
- SetObjProperty(cadaver, "cut","1");
- var corpseitm := conf[tmplate]."corpseitm";
- var corpseamt := conf[tmplate]."corpseamt";
- print("I: " + corpseitm);
- print("A: " + corpseamt);
- if(!corpseitm)
- print("error");
- var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
- sleep(30);
- DestroyItem(cadaver);
- sleep(30);
- DestroyItem(theblood);
- return;
- endif
- var i := 1;
- corpseitm := SplitWords(corpseitm);
- corpseamt := SplitWords(corpseamt);
- foreach thing in corpseitm
- CreateItemInContainer(cadaver, thing, Cint(corpseamt[i]));
- i := i + 1;
- endforeach
- SendSysMessage(who, "You place the items on the corpse.");
- var theblood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, UOBJ_BLOOD, 1);
- sleep(30);
- DestroyItem(cadaver);
- sleep(30);
- DestroyItem(theblood);
- endif
- endif
- endfunction
- function CarveLogs(who, blade, logs)
- if(logs.movable == 0)
- SendSysMessage(who, "You cannot use those logs.");
- return;
- endif
- if((!Accessible(who, logs)) or (!CheckLineOfSight(who, logs)) or (dist(who, logs) > 2))
- SendSysMessage(who, "You cannot use that");
- return;
- endif
- if(!logs.container)
- if(Distance(who, logs) > 2)
- SendSysMessage(who, "That is too far away");
- return;
- endif
- endif
- var creatable := CreatableObjects(who, blade, logs);
- var selection := SelectMenuItem2(who, "BowcraftCarving");
- if(!selection)
- return;
- endif
- var what := selection.objtype;
- if(!Accessible(who, logs))
- SendSysMessage(who, "I can't access the logs to make that.");
- return;
- endif
- var objectconfig := FindConfigElem(bowcraftconfigfile, what);
- if(!objectconfig)
- return;
- endif
- var material := CInt(GetConfigString(objectconfig, "Material"));
- if(material > logs.amount)
- SendSysMessage(who, "You don't have enough logs to make that.");
- return;
- endif
- var difficulty := GetConfigInt(objectconfig, "Difficulty");
- var pointvalue := GetConfigInt(objectconfig, "PointValue");
- var bow := 0;
- Detach();
- PlaySoundEffect(who, 0x5a);
- PerformAction(who, 0x021);
- sleep(2);
- PlaySoundEffect(who, 0x5a);
- PerformAction(who, 0x021);
- sleep(2);
- PlaySoundEffect(who, 0x5a);
- PerformAction(who, 0x021);
- sleep(2);
- PlaySoundEffect(who, 0x5a);
- PerformAction(who, 0x021);
- sleep(2);
- if(CheckSkill(who, SKILLID_BOWCRAFT, difficulty, pointvalue))
- if(what == UOBJ_SHAFTS)
- var amt := logs.amount;
- if(DestroyItem(logs))
- CreateItemInBackpack(who, what, amt);
- CheckToolWear (who, blade, SKILLID_BOWCRAFT);
- SendSysMessage(who, "You create some shafts and place them in your pack." );
- endif
- elseif (what == UOBJ_BOW)
- if(SubtractAmount(logs, material))
- bow := CreateItemInBackpack(who, what);
- CheckToolWear (who, blade, SKILLID_BOWCRAFT);
- SendSysMessage(who, "You create a bow and place it in your pack.");
- SetName(bow, "a bow");
- endif
- elseif (what == UOBJ_XBOW)
- if(SubtractAmount(logs, material))
- bow := CreateItemInBackpack(who, what);
- CheckToolWear (who, blade, SKILLID_BOWCRAFT);
- SendSysMessage(who, "You create a crossbow and place it in your pack.");
- SetName(bow, "a crossbow");
- endif
- elseif (what == UOBJ_HEAVY_XBOW)
- if(SubtractAmount(logs, material))
- bow := CreateItemInBackpack(who, what);
- CheckToolWear (who, blade, SKILLID_BOWCRAFT);
- SendSysMessage(who, "You create a heavy crossbow and place it in your pack.");
- SetName(bow, "a heavy crossbow");
- endif
- else
- SendSysMessage(who, "I don't know how to make that.");
- return;
- endif
- if((RandomInt(CInt(GetEffectiveSkill(who,SKILLID_BOWCRAFT)) + 1) > (difficulty + 20)) && (bow != 0))
- setquality(who, bow);
- // var skill := GetEffectiveSkill(who, SKILLID_BOWCRAFT);
- // ExceptionalFameMod(who, skill, difficulty, pointvalue);
- endif
- else
- SubtractAmount(logs, (RandomInt(5) + 1));
- SendSysMessage(who, "You destroy some logs.");
- endif
- endfunction
- function ExtractPearls(who, blade, seashell)
- // STILL NEED TO ADD A CHECK FOR BLADE OBJTYPES
- // SO YOU CAN ONLY USE KNIVES TO EXTRACT
- var skill := GetEffectiveSkill(who, SKILLID_FISHING);
- if((!Accessible(who, seashell)) or (!CheckLineOfSight(who,seashell)))
- SendSysMessage(who, "You cannot use that");
- return;
- endif
- if(Distance(who, seashell) > 2)
- SendSysMessage(who, "You are not close enough");
- return;
- endif
- if(skill < 50.0)
- SendSysMessage(who, "You don't know how to do that.");
- return;
- endif
- SendSysMessage(who, "Extracting pearls...");
- PlaySoundEffect(who, 0x5a);
- PerformAction(who, 0x021);
- sleep(2);
- SendSysMessage(who, "Extracting pearls...");
- PlaySoundEffect(who, 0x5a);
- PerformAction(who, 0x021);
- sleep(2);
- SendSysMessage(who, "Extracting pearls...");
- PlaySoundEffect(who, 0x5a);
- PerformAction(who, 0x021);
- sleep(2);
- if(Distance(who, seashell) > 2) //IF PLAYER MOVED MORE THAN 2 TILES FROM BEGINNING OF EXTRACTION STOP THE SCRIPT
- SendSysMessage(who, "You are not close enough");
- return;
- endif
- var randomness;
- if(skill >= 50.0 && skill <= 59.9)
- randomness := RandomInt(30);
- if (randomness != 1)
- givePearls(who, 2, seashell);
- else
- SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
- return;
- endif
- elseif(skill >= 60.0 && skill <= 79.9)
- randomness := RandomInt(20) + 1;
- if (randomness != 1)
- givePearls(who, 4, seashell);
- else
- SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
- return;
- endif
- elseif(skill >= 80.0 && skill <= 99.9)
- randomness := RandomInt(10);
- if (randomness != 1)
- givePearls(who, 6, seashell);
- else
- SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
- return;
- endif
- elseif(skill >= 100.0)
- randomness := RandomInt(1000);
- if (randomness != 1)
- givePearls(who, 10, seashell);
- else
- SendSysMessage(who, "You failed to extract the pearls and destroyed the shell.");
- return;
- endif
- endif
- endfunction
- function givePearls(who, how_many, shell)
- CreateItemInBackpack( who, 3962, how_many );
- SendSysMessage(who, "You successfully harvested "+how_many+" black pearls");
- DestroyItem(shell);
- endfunction
- function ExceptionalFameMod(who, skill, diff, points)
- if(skill > (diff - 20))
- if((skill - diff) <= 5)
- points := points;
- elseif((skill - diff) <= 10)
- points := (points * 3) / 4;
- elseif((skill - diff) <= 15)
- points := points / 2;
- elseif((skill - diff) <= 20)
- points := points / 4;
- else
- points := 0;
- endif
- points := Cint(points);
- var fame := Cint(GetObjProperty(who, "Fame"));
- var famegain := fame + points;
- SetObjProperty(who, "Fame", famegain);
- var msgtext := "You have ";
- if(points < 0)
- msgtext := msgtext + "lost ";
- points := Abs(points);
- else
- msgtext := msgtext + "gained ";
- endif
- if(points > 150)
- msgtext := msgtext + "a great amount of ";
- elseif(points > 125)
- msgtext := msgtext + "alot of ";
- elseif(points > 75)
- msgtext := msgtext + "a good amount of ";
- elseif(points > 30)
- msgtext := msgtext + "some ";
- elseif(points > 0)
- msgtext := msgtext + "a little ";
- else
- return 0;
- endif
- msgtext := msgtext + "Fame.";
- SendSysMessage(who, msgtext);
- var karma := Cint(GetObjProperty(who, "Karma"));
- var kmod := GetKarmaLevel(karma);
- var fmod := GetFameLevel(famegain);
- var newtitle := nototitles[ (kmod) ];
- newtitle := "The " + CStr(newtitle[fmod]) + " ";
- if(newtitle["None"])
- newtitle := "";
- endif
- if(fmod == 5)
- if(who.gender == 1)
- newtitle := newtitle + "Lady ";
- else
- newtitle := newtitle + "Lord ";
- endif
- endif
- if(newtitle != who.title_prefix)
- who.title_prefix := newtitle;
- SendSysMessage(who, "you are now known as " + newtitle + who.name);
- endif
- SetNotoTitle(who, karma, fame);
- endif
- endfunction
- function setquality(who, bow)
- var tname := TruncateArticle(bow.name);
- if(CInt(GetEffectiveSkill(who, SKILLID_BOWCRAFT)) >= 99)
- bow.name := "an exceptional " + tname + " [crafted by " + who.name + "]";
- else
- bow.name := "an exceptional " + tname;
- endif
- bow.quality := bow.quality + 0.2;
- bow.hp := bow.maxhp;
- SendSysMessage(who, "You created an exceptional item.");
- endfunction
Add Comment
Please, Sign In to add comment