Re-Melting or is it Re-Smelting

For questions relating to POL scripting (not necessarily related to WoD)

Moderators: Siobhan, Sebastian, Drocket

Re-Melting or is it Re-Smelting

Postby Grae on Wed Aug 20, 2003 3:08 am

Hiya,

Just curious, is it possible to re-smelt player crafted items. I have not been able to find anything in the scripts or the manual, so I gather you can't.

But would it be possible to script? I am using the WoD scripts with slight modifications. I am adept at reading and modifying scripts (I can figure them out), but am totally useless at writting them. But I guess everyone has to start somewhere, and I guess this would be as good a task as any to start on.

But what I am aiming at is say Miner whom has the smelting ability, to be able to re-melt Blacksmith and Tinker ore crafted items back into ingots, but with say a 50% lose of ingots. For example it might take 10 ingots to make a helm, when it's re-melted you could get up to 5 ingots back. Same deal with Gold crafted items like jewelry.

If anyone has a script similar to this already, may I have a look to get an idea of what to do. If not where would be the best place to get pointers as how to do this.

Thanks in advance.

Peace Out.
Grae
Sr. Newbie
 
Posts: 25
Joined: Sat Aug 02, 2003 5:56 am

Postby Lyl on Wed Aug 20, 2003 3:43 am

Ok, I made a quick little script for you to read. It doesn't handle tinkered items, but you could add that by making a function to tell if an item is a metal tinkered item.

Code: Select all
use uo;
use os;
use util;
use cfgfile;

include "include/client";
include "include/itemtypes";
include "include/objtype";
//?
include "include/yesno";
include "include/makemenu";
include "include/string";
include "include/magicitems";
include "include/crafting";
include "../pkg/skills/craftingskills/blacksmithy/blacksmithy";


program melt ( character , tongs )
   if (!ReserveItem (tongs))
      SendSysMessage (character, "You can't use that right now.");
      return;
   endif
   
   if (!Accessible (character, tongs))
      SendSysmessage (character, "You can't reach that.");
      return;
   endif

   SendSysmessage (character, "What metal would you like to melt?" );
   var use_on := Target (character);
   if (!use_on)
      SendSysmessage (character, "Canceled.");
      return;
   endif

   if (!Accessible (character, use_on) )
      SendSysmessage( character, "You can't reach that!" );
      return;
   endif

   if (!ReserveItem(use_on))
      SendSysmessage (character, "You cannot use that right now.");
      return;
   endif

   if (!FindForgeInArea (character))
      SendSysMessage (character, "You must be near a forge to melt items!");
      return;
   endif

   if ( !IsMetalWeapon (use_on) and !IsMetalArmor (use_on) and !IsMetalShield (use_on) )
      SendSysMessage (character, "You don't know how to use those together.");
      return;
   endif


   var smith_cfg_file := ReadConfigFile( ":blacksmithy:blacksmithy" );
   var elem := FindConfigElem (smith_cfg_file, use_on.objtype);

   if (!elem)
      SendSysMessage (character, "What is that?");
      return;
   endif

   var ammount := CINT ( elem.material / 2 );

   DestroyItem ( use_on );
   SendSysmessage ( character, "You melt the item." );
//   SendSysmessage ( character, "Amount: " + ammount );

   if ( CheckSkill (character, SKILLID_BLACKSMITHY, 55, 0 ) )
      var bars := CreateItemInBackpack ( character, UOBJ_IRON_INGOT, ammount );
      if (!bars)
         PrintTextAbovePrivate (character, "*Your backpack is full!*", character);
      endif
   else
      SendSysmessage (character, "You fail big time.");
   endif

endprogram


///////////////////
//  Searches the area around the character for a forge
///////////////////

function FindForgeInArea (character)
   foreach item in ListItemsNearLocation(character.x, character.y, character.z,2)
      if ( item.objtype >= UOBJ_FORGE_START and item.objtype <= UOBJ_FORGE_END )
         return 1;
      elseif (item.objtype = UOBJ_SMALL_FORGE)
         return 1;
      endif
   endforeach
   return 0;
endfunction
Lyl
Regular Poster
 
Posts: 109
Joined: Fri Oct 11, 2002 1:04 am

Postby Grae on Wed Aug 20, 2003 4:10 am

Thank you Kindly Lyl.
Grae
Sr. Newbie
 
Posts: 25
Joined: Sat Aug 02, 2003 5:56 am


Return to Scripting Forum

Who is online

Users browsing this forum: No registered users and 1 guest

cron