Page 1 of 1

Ok i broke down (Enchanted Jewelry Here)

PostPosted: Tue Mar 11, 2003 10:50 pm
by Kardall
I was going through my stuff... and i thought, ok i'll post this.

This is a really REALLY good enchanted (skill raising) jewely function. How you decide if they are going to "make" the jewelry, i leave up to you. But this is the complex task of the difficulty of making particular jewels... anyway...

Code: Select all
function EnchantJewelery(who, theitem, material)
   if (theitem.objtype < 0x1085 or theitem.objtype > 0x108a)
      return 0;
   endif
   local tinkeringskill := GetEffectiveSkill(who, SKILLID_TINKERING);
   local mageskill := GetEffectiveSkill(who, SKILLID_MAGERY);
   if (tinkeringskill < 100 or mageskill <75)
      return 0;
   endif
   if (cint(GetObjProperty(who, "#Tinkering_jewelery_delay")) > readgameclock())
      SendSysMessage(who, "You must wait " + ((cint(GetObjProperty(who, "#Tinkering_jewelery_delay")) - readgameclock()) / 60.0) + " minutes longer before you can make other piece of magic jewelery.");
      return 0;
   endif
   local maxlevel := (tinkeringskill - 100) / 5 + 1;
   if (maxlevel > 5) maxlevel := 5; endif
   local chosenlevel := randomint(maxlevel) + 1;

   local chance := 1.0;
   if (chosenlevel != maxlevel)
   //   chance := pow(1.5, (maxlevel - chosenlevel));
   ////   chance := pow(1.316074, (maxlevel - chosenlevel));
      local i;
      for (i:=0; i < maxlevel - chosenlevel; i:=i+1)
         chance := chance * 1.5;
      endfor
   endif

   local chancemult := 1.0;
   local chosenskill := randomint(49);

   case(chosenskill)
/*
   SKILLID_ALCHEMY:           chancemult := 1;
   SKILLID_ANATOMY:           chancemult := 1;
   SKILLID_ANIMALLORE:        chancemult := 1;
   SKILLID_ARMSLORE:          chancemult := 1;
   SKILLID_PARRY:             chancemult := 1;
   SKILLID_BOWCRAFT:          chancemult := 1;
   SKILLID_PEACEMAKING:       chancemult := 1;
   SKILLID_CAMPING:           chancemult := 1;
   SKILLID_CARPENTRY:         chancemult := 1;
   SKILLID_CARTOGRAPHY:       chancemult := 1;
   SKILLID_COOKING:           chancemult := 1;
   SKILLID_DETECTINGHIDDEN:   chancemult := 1;
   SKILLID_ENTICEMENT:        chancemult := 1;
   SKILLID_EVALINT:           chancemult := 1;
   SKILLID_HEALING:           chancemult := 1;
   SKILLID_FISHING:           chancemult := 1;
   SKILLID_FORENSICS:         chancemult := 1;
   SKILLID_HERDING:           chancemult := 1;
   SKILLID_PROVOCATION:       chancemult := 1;
   SKILLID_INSCRIPTION:       chancemult := 1;
   SKILLID_LOCKPICKING:       chancemult := 1;
   SKILLID_MAGERY:            chancemult := 1;
   SKILLID_TACTICS:           chancemult := 1;
   SKILLID_SNOOPING:          chancemult := 1;
   SKILLID_MUSICIANSHIP:      chancemult := 1;
   SKILLID_POISONING:         chancemult := 1;
   SKILLID_ARCHERY:           chancemult := 1;
   SKILLID_SPIRITSPEAK:       chancemult := 1;
   SKILLID_STEALING:          chancemult := 1;
   SKILLID_TASTEID:           chancemult := 1;
   SKILLID_TRACKING:          chancemult := 1;
   SKILLID_VETERINARY:        chancemult := 1;
   SKILLID_SWORDSMANSHIP:     chancemult := 1;
   SKILLID_MACEFIGHTING:      chancemult := 1;
   SKILLID_FENCING:           chancemult := 1;
   SKILLID_WRESTLING:         chancemult := 1;
   SKILLID_LUMBERJACKING:     chancemult := 1;
   SKILLID_MINING:            chancemult := 1;
   SKILLID_MEDITATION:        chancemult := 1;
   SKILLID_STEALTH:           chancemult := 1;
*/
   SKILLID_REMOVETRAP:        chancemult := 2.0;
   SKILLID_HIDING:            chancemult := 2.0;
   SKILLID_BEGGING:           chancemult := 1.5;
   SKILLID_MAGICRESISTANCE:   chancemult := 0.6666;
   SKILLID_BLACKSMITHY:       chancemult := 0.5;
   SKILLID_TAILORING:         chancemult := 0.5;
   SKILLID_TAMING:            chancemult := 0.5;
   SKILLID_TINKERING:         chancemult := 0.3333;

   endcase
   chancemult := chancemult * material / 4.0;  // should be 6 but due to the additional cost of having to use gems, for now it is 2mil + 350k in gems instead of 3mil + 525k in gems regular.

   if (who.cmdlevel > 3)
      SendSysMessage(who, "Chance = " + chancemult * 100.0 * chance);
      SendSysMessage(who, "Maxlevel = " + maxlevel);
      SendSysMessage(who, "Chosenlevel = " + chosenlevel);
      SendSysMessage(who, "Chancemult = " + chancemult);
      SendSysMessage(who, "Skillid = " + chosenskill);
   endif

   if (randomint(10000) < chancemult * 100.0 * chance or who.cmdlevel > 4)
      // successful!
      set_critical(1);
      local enchantment := array;
      enchantment[1] := chosenskill;
      enchantment[2] := chosenlevel * 5;
      SetObjProperty(theitem, "Enchantment", enchantment);

      local name := "";
      case(chosenskill)

         SKILLID_ALCHEMY:      name := " of ALCHEMY";
         SKILLID_ANATOMY:      name := " of ANATOMY";
         SKILLID_ANIMALLORE:      name := " of ANIMALLORE";
         SKILLID_ITEMID:         name := " of ITEMID";
         SKILLID_ARMSLORE:      name := " of ARMSLORE";
         SKILLID_PARRY:         name := " of PARRY";
         SKILLID_BOWCRAFT:      name := " of BOWCRAFT";
         SKILLID_PEACEMAKING:      name := " of PEACEMAKING";
         SKILLID_CAMPING:      name := " of CAMPING";
         SKILLID_CARPENTRY:      name := " of CARPENTRY";
         SKILLID_CARTOGRAPHY:      name := " of CARTOGRAPHY";
         SKILLID_COOKING:      name := " of COOKING";
         SKILLID_DETECTINGHIDDEN:   name := " of DETECTINGHIDDEN";
         SKILLID_ENTICEMENT:      name := " of ENTICEMENT";
         SKILLID_EVALINT:      name := " of EVALINT";
         SKILLID_HEALING:      name := " of HEALING";
         SKILLID_FISHING:      name := " of FISHING";
         SKILLID_FORENSICS:      name := " of FORENSICS";
         SKILLID_HERDING:      name := " of HERDING";
         SKILLID_PROVOCATION:      name := " of PROVOCATION";
         SKILLID_INSCRIPTION:      name := " of INSCRIPTION";
         SKILLID_LOCKPICKING:      name := " of LOCKPICKING";
         SKILLID_MAGERY:         name := " of MAGERY";
         SKILLID_TACTICS:      name := " of TACTICS";
         SKILLID_SNOOPING:      name := " of SNOOPING";
         SKILLID_MUSICIANSHIP:      name := " of MUSICIANSHIP";
         SKILLID_POISONING:      name := " of POISONING";
         SKILLID_ARCHERY:      name := " of ARCHERY";
         SKILLID_SPIRITSPEAK:      name := " of SPIRITSPEAK";
         SKILLID_STEALING:      name := " of STEALING";
         SKILLID_TASTEID:      name := " of TASTEID";
         SKILLID_TRACKING:      name := " of TRACKING";
         SKILLID_VETERINARY:      name := " of VETERINARY";
         SKILLID_SWORDSMANSHIP:      name := " of SWORDSMANSHIP";
         SKILLID_MACEFIGHTING:      name := " of MACEFIGHTING";
         SKILLID_FENCING:      name := " of FENCING";
         SKILLID_WRESTLING:      name := " of WRESTLING";
         SKILLID_LUMBERJACKING:      name := " of LUMBERJACKING";
         SKILLID_MINING:         name := " of MINING";
         SKILLID_MEDITATION:      name := " of MEDITATION";
         SKILLID_STEALTH:      name := " of STEALTH";

         SKILLID_REMOVETRAP:      name := " of REMOVETRAP";
         SKILLID_HIDING:         name := " of HIDING";
         SKILLID_BEGGING:      name := " of BEGGING";
         SKILLID_MAGICRESISTANCE:   name := " of MAGICRESISTANCE";
         SKILLID_BLACKSMITHY:      name := " of BLACKSMITHY";
         SKILLID_TAILORING:      name := " of TAILORING";
         SKILLID_TAMING:         name := " of TAMING";
         SKILLID_TINKERING:      name := " of TINKERING";
      endcase

      local delay := 0;
      name := lower(name);
      local name2 := "";
      case (chosenlevel)
         1: name2 := "a lesser ";   delay := 60 * 2;   theitem.color := 63;
         2: name2 := "a good ";      delay := 60 * 6;   theitem.color := 13;
         3: name2 := "a greater ";   delay := 60 * 25;   theitem.color := 88;
         4: name2 := "a glorious ";   delay := 60 * 120;   theitem.color := 3;
         5: name2 := "a godly ";      delay := 60 * 480;   theitem.color := 38;
      endcase
//         theitem.desc := name2 + theitem.desc + name;
         if (theitem.desc[1,2] = "a ")
            theitem.name := theitem.desc[3,15];
         else
            theitem.name := theitem.desc;
         endif
         theitem.name := name2 + theitem.name + name;
      set_critical(0);

      SetObjProperty(who, "#Tinkering_jewelery_delay", readgameclock() + delay);
      return 1;
   endif
   return 0;
endfunction


Enjoy, use it, spread it around... it's great.

PostPosted: Wed Mar 12, 2003 5:18 pm
by bulldogc
without looknig at the script as i dont have alota time rightnow. is this the im gona give u the bonus code or the creation code?

PostPosted: Fri Mar 14, 2003 8:29 am
by Kardall
uhm... this basically does the calculations on what kind of jewel it is (skill), the level of it (lesser, good, greater, glorious, godly)

It has chance multipliers because some jewels may be more desireable, so make them really ass hard to get... ie Tinker (needed to make jewels).

I saw IS's jewel script, and this is different. IS doesn't have the chance multipliers... some people may like it, some may not... *shrug* i just made it available...

The part that i did not include, is simple. It's the part where you say (ie):

"Clicked make a bracelet"
"I have 100 Tink so I have X percent to make a lesser jewel now..."

the X percent calculations are your task, as are the timer (if u wish) on which to base whether or not, even if they CAN make one, does a timer allow them to make one yet or not. ie: if u make a lesser, timer is 10min., good the timer is 30min., greater 120min. etc... whatever...

PostPosted: Fri Mar 14, 2003 5:18 pm
by bulldogc
yea i saw that when i got home earlier and checked throguh it. its kinda nifty