PenUltima Online

It is currently Sat Sep 06, 2008 9:24 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: New Logs.
PostPosted: Sun May 21, 2006 9:14 am 
Offline

Joined: Sat Apr 15, 2006 11:50 am
Posts: 66
Hello, Ive thought for a long time how to do new logs.
But i have no idea how to do :cry:

If someone could gimme a hint i would appreciate it very much :D






Code:
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 8:21 am 
Offline

Joined: Sat Apr 15, 2006 11:50 am
Posts: 66
:cry:


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 9:19 am 
Offline

Joined: Wed Apr 19, 2006 12:29 pm
Posts: 42
Location: St. Peters, MO
Damien,

You create entries in your itemdesc.cfg files for the logs. You need to assign a unique Item number (hex number not used by anything else) and drop in an entry calling the graphic number for a log, but with a different name (like cherrywood) and perhaps a different color.

_________________
Obstacles cannot crush me; every obstacle yields to Stern Resolve.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 11:56 am 
Offline

Joined: Sat Apr 15, 2006 11:50 am
Posts: 66
Hello Exar thx for replying :D


Yeah i know that part..
But does that automaticcly let me lumberjack those logs?
Or do i have to change anything else?


Sry i have to ask...
Or else i cant learn.
:mrgreen:



Code:
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 12:01 pm 
Offline

Joined: Wed Apr 19, 2006 12:29 pm
Posts: 42
Location: St. Peters, MO
There is indeed more you have to do.

You need to find your resource system. Somewhere, there will be a list of the resources that are spawned/harvested. Your new log entries must go in the same place and follow the same format.

I'd try to be more specific, but I know there are many resource spawners floating around out there.

_________________
Obstacles cannot crush me; every obstacle yields to Stern Resolve.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 2:08 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
Here is some of my custom log stuff from Hope Lives version 1. I have copied the part in the original Hope lumberjack.src file that created custom logs based on the treetype being chopped to the POL 95 Distro lumberjack source file. Keep in mind a couple of things:

1. I have done this on the fly and did not check to be sure that this will work flawlessly with POL 95 yet but I will soon. Since I am starting over with the POL 95 Distro myself, I had to research how I did it originally so I want to thank Damien for his question.

2. You should assign objtypes (Item numbers) starting at or above 0x4000 to your custom items. The reason for this is because the art tiles use numbers 0x0000 through 0x3fff. Understand when I wrote the original scripts I was new to POL/UO and didn't realize this. That's the reason for Yew logs having th item number 0x1c15.

I rely on the basic entry for wood.cfg in the \pol\regions\ to manage my wood resources rather than try to enter a cfg file for each specific type of wood. So there is no need for any special resource management with my idea. You could make entries for each type if you wanted say Yew trees to give more wood than regular trees. They are bigger than regular trees after-all butI was lazy :).


Entry for itemdesc.cfg file (be sure to change Item number to an item not in use; see objtypes.txt in main POL directory for items currently in use. Should be 0x4000 or greater):

Code:
Item 0x1c15
{
    Name                yewlog
    desc                yew log%s%
    graphic             0x1bdd
    color               0x002c
    Weight      1/2
    VendorSellsFor      10
    VendorBuysFor       1
}



Here is my version of the POL 95 lumberjack script modified with some of my original work. I have only provided the example of Yew logs here as a new item but if you look at what I have done you can see how to create more based on the treetype chopped. See the Do_Chops function to see where I modified the script.

Code:
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/utility";
include "include/dist";
include "include/toolWear";
include "include/noto";

const UACTION_CHOP := 0x0d;
const FX_POISON_GAS := 0x113a;
var bowcraftconfigfile := ReadConfigFile("::bowcraft");
var mex;
var mey;

program use_axe(me, axe)
  EraseObjProperty(me, "IsMeditating");
  EraseObjProperty(me, "HealTimer");
  if(!can_access(me, axe))
    return;
  endif
  if(!ReserveItem(axe))
    return;
  endif
  if(!IsAxEquipped(me, axe))
    SendSysMessage(me,"You have to equip that to lumberjack!");
    return;
  endif
  var tree := TreeNearby(me, axe);
  if(!tree)
    return;
  endif
  SendSysMessage(me, "You begin chopping...");
  var checker := 0;
  mex := me.x;
  mey := me.y;
  var mount;
  repeat
    mount := GetEquipmentByLayer(me, 25);
    if(mount)
      SendSysMessage(me,"you cannot chop wood while on horseback.");
      return;
    endif
    if(!axe)
      return;
    endif
    PerformAction(me, UACTION_CHOP);
    PlaySoundEffect(me, SFX_SKILL_LUMBERJACK);
    sleepms(2500);
    checker := Do_Chops(me, axe, tree);
  until(checker == 1);
endprogram


function Do_Chops(me, axe, tree)
  var difficulty := GetHarvestDifficulty("wood", tree.x, tree.y, tree.objtype, me.realm);
  if(difficulty == error)
    SendSysMessage(me, "There's not enough wood here to chop");
    return 1;
  endif
  if((me.x != mex) || (me.y != mey))
    SendSysMessage(me,"You stop chopping.");
    return 1;
  endif
  var points := CInt((GetEffectiveSkill(me, SKILLID_LUMBERJACKING) * 2) + 10);

// This is where I modified the original lumberjack script.
// I do a CheckSkill with my new definition of dificulty (the var diffi) based on the type of tree being chopped.
  var diffi := 0;
    case (tree.objtype)
      0x0cc9 : diffi := 95; // spider tree
      0x12b8 : diffi := 85; // yew tree
      0x12b9 : diffi := 85; // yew tree
      0x12ba : diffi := 85; // yew tree
      0x12bb : diffi := 85; // yew tree
      0x0cdd : diffi := 75; // Oak tree
      0x0cda : diffi := 75; // Oak tree
      0x0ce0 : diffi := 70; // walnut tree
      0x0cd8 : diffi := 65; // Cedar tree
      0x0cd6 : diffi := 65; // Cedar tree
      0x0ce6 : diffi := 60; // Cypress tree
      0x0c9e : diffi := 40; // Ash tree
    endcase;
  if (GetAttribute (me, "Lumberjacking") < diffi)
      SendSysMessage(me, "You fail to find any usable wood here.");
      return 1;
  endif
// OK here is where I am going to add my custom log case statement

    case (tree.objtype)
      0x12b8 : logtype := 0x1c15; // yew log
      0x12b9 : logtype := 0x1c15; // yew log
      0x12ba : logtype := 0x1c15; // yew log
      0x12bb : logtype := 0x1c15; // yew log
      default: logtype := 0x1bdd; // Regular plain old logs
    endcase;
// End of my modification (sort of)
  if(CheckSkill(me, SKILLID_LUMBERJACKING, diffi, points))
    var wood_amount := HarvestResource( "wood", tree.x, tree.y, 1, 10, me.realm );
    if(wood_amount == 0)
      SendSysMessage(me, "There's not enough wood here to chop.");
      return 1;
    endif
    if(!CreateItemInBackpack(me, logtype, wood_amount))
      SendSysMessage(me, "Your backpack is too full.");
      return 1;
    else
      SendSysMessage(me, "You put some logs in your backpack");
      CheckToolWear (me, axe, SKILLID_LUMBERJACKING);
      return 0;
    endif
  else
    SendSysMessage(me, "You fail to get any usable wood.");
    return 0;
  endif
endfunction

function TreeNearby(me, axe)
  SendSysMessage( me, "Select something to chop." );
  var tree := TargetCoordinates( me );
  if(!tree)
    SendSysMessage(me, "Cancelled");
    return 0;
  endif
  var distt := coordist( me.x, me.y, tree.x, tree.y );
  if(distt > 1 )
    if(!tree.item.container)
      SendSysMessage(me,"That is too far away");
      return 0;
    endif
  endif
  if(is_furniture(tree.item.objtype, tree.item))
    chopfurniture(me, tree.item);
    return 0;
  elseif(is_tree(tree.objtype))
    var difficulty := GetHarvestDifficulty( "wood", tree.x, tree.y, tree.objtype, me.realm );
    if(difficulty == error)
      SendSysMessage(me, "There's not enough wood here to chop.");
      return 0;
    endif
    return tree;
  else
    use_blade(me, axe, tree.item);
    return 0;
  endif
endfunction

function is_furniture(theobj, thing)
  var miscobjtypes := { 0x7007, 0xa30, 0xa34, 0xa38, 0xfae, 0x9e40};
  if((theobj >= 0x9a8) && (theobj <= 0x9ab))
    return 1;
  elseif((theobj >= 0xa2a) && (theobj <= 0xa2c))
    return 1;
  elseif((theobj >= 0xa4c) && (theobj <= 0xa53))
    return 1;
  elseif((theobj >= 0xa97) && (theobj <= 0xa9e))
    return 1;
  elseif((theobj >= 0xb2c) && (theobj <= 0xb40))
    return 1;
  elseif((theobj >= 0xb49) && (theobj <= 0xb90))
    return 1;
  elseif((theobj >= 0xe3c) && (theobj <= 0xe43))
    return 1;
  elseif((theobj >= 0xe7c) && (theobj <= 0xe80))
    return 1;
  elseif((theobj >= 0xf65) && (theobj <= 0xf77))
    return 1;
  elseif(theobj in miscobjtypes)
    return 1;
  elseif(GetObjProperty(thing, "ItemsCreatedSerials"))
    return 1;
  else
    return 0;
  endif
endfunction

function is_tree(theobj)
  if((theobj >= 0x0c99) && (theobj <= 0x0cea))
    return 1;
  elseif((theobj >= 0x0cf3) && (theobj <= 0x0d03))
    return 1;
  elseif((theobj >= 0x0d41) && (theobj <= 0x0dab))
    return 1;
  elseif((theobj >= 0x12b6) && (theobj <= 0x12c7))
    return 1;
  elseif((theobj >= 0x0d37) && (theobj <= 0x0d38))
    return 1;
  elseif((theobj == 0x0c9e) || (theobj == 0x0ca8) || (theobj == 0x0caa) || (theobj == 0x0cab))
    return 1;
  else
    return 0;
  endif
endfunction


function IsAxEquipped(me,axe)
  if((!Accessible(me,axe)) || (Distance(me, axe) > 1))
    return 0;
  endif
  foreach item in ListEquippedItems(me)
    if (axe.serial == item.serial )
      return 1;
    endif
  endforeach
  return EquipItem(me, axe );
endfunction

function chopfurniture(me, theobj)
  if(!can_access(me, theobj))
    return;
  endif
  var sign;
  if(GetObjProperty(theobj, "lockeddown") || GetObjProperty(theobj, "secure"))
    SendSysMessage(me, "You cannot destroy secure or locked down items.");
    return;
  endif
  if(theobj.objtype == 0x7007)
    var houseserial := GetObjProperty(theobj, "houseserial");
    sign := SystemFindObjectBySerial(houseserial);
    if(GetObjProperty(sign, "barrelserial") == theobj.serial)
      EraseObjProperty(sign, "barrelserial");
      SendSysMessage(me, "you cannot destroy that while it is locked down.");
      return;
    endif
  endif
  if(!Accessible(me, theobj))
    SendSysMessage(me, "you cant reach that");
    return;
  endif
  if(me.multi)
    if(GetObjProperty((me.multi), "ownerserial") != me.serial)
      var house := me.multi;
      foreach thing in (house.components)
        if((thing.objtype == 0x0bd0) || (thing.objtype == 0x0bd2))
          sign := thing;
          break;
        endif
      endforeach
      var coowner := 0;
      var coownerlist := GetObjProperty(sign, "coownerlist");
      foreach thing in coownerlist
        if(thing == me.serial)
          coowner := 1;
          break;
        endif
      endforeach
      if(!coowner)
        SendSysMessage(me, "this does not belong to you!");
        return;
      endif
    endif
  endif
  foreach thing in EnumerateItemsInContainer(theobj)
    if(theobj.container)
      MoveItemToContainer(thing, theobj.container);
    else
      MoveObjectToLocation(thing, theobj.x, theobj.y, theobj.z, theobj.realm, MOVEITEM_FORCELOCATION);
    endif
  endforeach
  if(theobj.usescript == ":tinkering:tinkerTraps")
    var traptype := GetObjProperty(theobj,"trap_type");
    var trapstrength := GetObjProperty(theobj,"trap_strength");
    var trapperserial := CInt(GetObjProperty(theobj, "trapper"));
    var trapper := SystemFindObjectBySerial(trapperserial, SYSFIND_SEARCH_OFFLINE_MOBILES);
    if(trapper)
      SetObjProperty(me, "LastHit", {trapper.name, trapper.serial, "trapped chest" });
      SetScriptController(trapper);
    endif
    case (traptype)
      "1" :   PlaySoundEffect(me, SFX_224);
              var dmg := (RandomInt(20) + CInt(trapstrength));
              SendSysMessage(me, "You set off a needle trap!");
              ApplyDamage(me, dmg);
              theobj.usescript := "";
              EraseObjProperty( theobj, "trap_type" );
              EraseObjProperty( theobj, "trap_strength" );

      "2" :   start_script(":traps:poisonTrapTriggered", {me, theobj, "You set off a poison trap!", trapstrength});

      "3" :   PlaySoundEffect(me, SFX_208);
              SendSysMessage(me, "You set off an explosion trap!");
              PlayObjectCenteredEffect( me, FX_EXPLODE_3, 10,10);
              var dmg := (RandomInt(20) + CInt(trapstrength));
              ApplyRawDamage(me, dmg);
              theobj.usescript := "";
              EraseObjProperty( theobj, "trap_type" );
              EraseObjProperty( theobj, "trap_strength" );
    endcase
  endif
  var created := GetObjProperty(theobj, "ItemsCreatedSerials");
  if(created)
    var holder;
    foreach thing in created
      holder := SystemFindObjectBySerial(thing);
      if(holder)
        DestroyItem(holder);
      endif
    endforeach
  else
    DestroyItem(theobj);
  endif
  PlaySoundEffect(me, 0x13a);
  return;
endfunction

function use_blade(who, blade, use_on)
  if(!can_access(who,use_on))
    return;
  endif
  if(!ReserveItem(use_on))
    return;
  endif
  var checkme := use_on.objtype;
  if((checkme == UOBJ_LOGS) || (checkme == 0x1bd7))
    CarveLogs(who, blade, use_on);
  elseif(use_on.npctemplate == "sheep")
    process_wool(who, blade, use_on);
  elseif(use_on.objtype == UOBJ_CORPSE)
    ReleaseItem(blade);
    Carve_Corpse(who, use_on);
  elseif(is_fish(checkme))
    CarveFish(who, blade, use_on);
  else
    SendSysMessage(who, "I don't know how to use those items together.");
  endif
endfunction

function process_wool(who, blade, sheep)
  if(sheep.graphic == 207)
    sheep.graphic := 223;
    CreateItemInContainer(who.backpack, 0xf125, 3);
    CheckToolWear (who, blade, SKILLID_TAILORING);
  else
    SendSysMessage(who,"That sheep is not yet ready to be shorn.");
  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 CarveFish(who, blade, use_on)
  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);
    CheckToolWear (who, blade, SKILLID_FISHING);
    SendSysMessage(who, "You carve the fish steaks and put them in your backpack");
  endif
  sleep(1);
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)
      MoveObjectToLocation(thing, cadaver.x, cadaver.y, cadaver.z, cadaver.realm, 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
        MoveObjectToLocation(thing, cadaver.x, cadaver.y, cadaver.z, cadaver.realm, MOVEITEM_FORCELOCATION);
      endif
    endforeach
    var partsarray := {};
    var part;
    part := CreateItemAtLocation(cadaver.x-1, cadaver.y, cadaver.z, 0x1da0, 1, who.realm);
    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, who.realm);
    partsarray.append(part);
    part := CreateItemAtLocation(cadaver.x-1, cadaver.y+1, cadaver.z, 0x1da2, 1, who.realm);
    partsarray.append(part);
    part := CreateItemAtLocation(cadaver.x+1, cadaver.y, cadaver.z, 0x1da3, 1, who.realm);
    partsarray.append(part);
    part := CreateItemAtLocation(cadaver.x+1, cadaver.y+1, cadaver.z, 0x1da4, 1, who.realm);
    partsarray.append(part);
    part := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, 0x1d9f, 1, who.realm);
    partsarray.append(part);
    var blood := CreateItemAtLocation(cadaver.x, cadaver.y, cadaver.z, 0x122a, 1, who.realm);
    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, who.realm);
      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, who.realm);
      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, who.realm);
        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, who.realm);
      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))
    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 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
    var myskill := CInt(GetEffectiveSkill(who, SKILLID_BOWCRAFT));
    var modpts := 0;
    if(myskill >=  difficulty)
      modpts := (myskill - difficulty);
    endif
    var rint := RandomInt(100);
    if(modpts >= rint)
      ExceptionalFameMod(who, myskill, difficulty, Cint(pointvalue / 2));
      setquality(who, bow);
    endif
  else
    SubtractAmount(logs, (RandomInt(5) + 1));
    SendSysMessage(who, "You destroy some logs.");
  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

function ExceptionalFameMod(who, skill, diff, points)
  if(skill > diff - 20)
    diff := 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



I hope this helps you out Damien. Ofcourse understand that these logs still won't have any special abilities and you will have to be responsible for transferring the colour of the logs to any item crafted from them but I hope I have given you a hand up to creating something special for your shard.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Last edited by Yukiko on Tue May 23, 2006 10:40 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 4:30 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
Please note, I found a bug in the above script and edited the poat. If you used the script as originally posted you'll need to re-copy it and compile again

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 4:34 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
Also, if you want to change it so you need a minimum of skill to be able to get regular logs you will need to change this line:
Code:
  var diffi := 0;

to reflect that minimum skill.

For example as it stands now you don't need any skill in lumberjacking to get plain logs. Change the 0 to 10 and you then will need atleast ten points to lumberjack regular logs.

Actually now that I think about it you could make that a default of the case statement but as I said earlier this was written way back in my early days of scripting.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 4:48 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
One more thing.

With this line in you won't get any logs until your skill in LJ is high enough and you won't gain skill at all. So I recommend removing it

Code:
  if (GetAttribute (me, "Lumberjacking") < diffi)
      SendSysMessage(me, "You fail to find any usable wood here.");
      return 1;
  endif

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 1:00 am 
Offline

Joined: Sat Apr 15, 2006 11:50 am
Posts: 66
Wauw your guys great! Thanks for all support it will surrerly help me.
And i guess it will help loads of other Escript beginners too :D

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 1:37 am 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
Sure thing Damien.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 2:01 am 
Offline

Joined: Sat Apr 15, 2006 11:50 am
Posts: 66
Ive tried it and i only get 1 error lucky enough ;D

Updated the script realized it was wrong ;P

This is what i get:
Code:
Compiling: Pol/pkg/skills/lumberjacking/lumberjack.src
Variable logtype has not been declared on line 86.
Error compiling statement at Pol\pkg\skills\lumberjacking\
lumberjack.src, Line 86
Error compiling statement at Pol\pkg\skills\lumberjacking\
lumberjack.src, Line 85
Error in function 'Do_Chops', File: Pol\pkg\skills\lumberj
acking\lumberjack.src, Line 86

Error in function Do_Chops
File: Pol\pkg\skills\lumberjacking\lumberjack.src, Line 86

Execution aborted due to: Error compiling file
Error in function Do_Chops
File: Pol\pkg\skills\lumberjacking\lumberjack.src, Line 87

Execution aborted due to: Error compiling file


And if i check the line:

Code:
  endif
  var points := CInt((GetEffectiveSkill(me, SKILLID_LUMBERJACKING) * 2) + 10);
    var diffi := 0;
    case (tree.objtype)
      0x0cc9 : diffi := 95; // dark tree
      0x0ce6 : diffi := 85; // oak tree
      0x0ce0 : diffi := 75; // pine tree
      0x0cd8 : diffi := 65; // sun tree
      0x0c9e : diffi := 55; // ash tree
      0x12b8 : diffi := 45; // yew tree
    endcase;
  if (GetAttribute (me, "Lumberjacking") < diffi)
      SendSysMessage(me, "You fail to find any usable wood here.");
      return 1;
  endif

    case (tree.objtype)
      0x12b8 : logtype := 0x4000; // yew log <-- Line 87
      0x0c9e : logtype := 0x4001; // ash log
      0x0cd8 : logtype := 0x4002; // sun log
      0x0ce0 : logtype := 0x4003; // pine log
      0x0ce6 : logtype := 0x4004; // oak log
      0x0cc9 : logtype := 0x4005; // dark log
      default: logtype := 0x1bdd; // Regular plain old logs
    endcase;


Here is also my Objtype:
Code:
////////////////////////////////////////////
////////Logs and Woodtypes////////////////
///////////////////////////////////////////

const UOBJ_YEW_LOGS     := 0x4000;
const UOBJ_ASH_LOGS     := 0x4001;
const UOBJ_SUN_LOGS     := 0x4002;
const UOBJ_PINE_LOGS    := 0x4003;
const UOBJ_OAK_LOGS     := 0x4004;
const UOBJ_DARK_LOGS    := 0x4005;

/////////////////////////////////
///////TREES//////////////////////
//////////////////////////////////

const UOBJ_DARK_TREE    := 0x0cc9;
const UOBJ_OAK_TREE     := 0x0ce6;
const UOBJ_PINE_TREE    := 0x0ce0;
const UOBJ_SUN_TREE     := 0x0cd8;
const UOBJ_ASH_TREE     := 0x0c9e;
const UOBJ_YEW_TREE     := 0x12b8;


Someone see anything that is wrong? ;D

Thanks.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 5:28 am 
Offline

Joined: Sat Apr 15, 2006 11:50 am
Posts: 66
Fixed Thanks for all who helped me: D


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 1:05 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
Sorry Damien. As I said I did that on the fly at the time and forgot this one entry right before the case.

Code:
// OK here is where I am going to add my custom log case statement
    var logtype := 0x1bdd; // Defaukt to regular logs if not in case.
    case (tree.objtype)


Note the var declaration right before the case.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 2:58 am 
Offline

Joined: Sat Apr 15, 2006 11:50 am
Posts: 66
Now there is just a small modification ( i think) too make the whole script
100% complete.

I still got some problem:

1. I cant lumberjack these logs :(
When i lumberjack i get the normal logs( I've tried different trees)

2.When i create for example a bench with yew logs,
the bench name is still just a bench and it got the normal color.

soo pls help me :

Make these logs lumberjackable and to make so when you create an item from the logs i created, it should have the name for example: a yew bench and also the yew log color.

Pls help :D


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 4:41 am 
Offline
User avatar

Joined: Sat Feb 04, 2006 8:17 am
Posts: 137
Location: Illinois, USA
As for your second statement you will have some code to your crafting scripts to set the color and the name.

I am using a modified version of the Sanctuary scripts myself and am not sure how the distro crafting system works when it comes to crafting. But here is how I did it with my scripts. This is only a small snippet of code to set the color and name.

Code:
   created_item.color := logs.color;
   created_item.name := "a " + log_name + " " + TruncateArticle(item_name) + " [crafted by " + character.name + "]";


This gets added into your carpentry script when the item is created.

_________________
2nd place is the 1st loser.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 9:35 am 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
Damien, did you create an entry for each new log you defined in the script? If not you'll need one.

Example:
Code:
Item 0x4001
{
    Name                yewlog
    desc                yew log%s%
    graphic             0x1bdd
    color               0x002c
    Weight      1/2
    VendorSellsFor      10
    VendorBuysFor       1
}


To add qualities to items based on wood type, in this example bows, you will need to edit each script that uses the wood, in this example bladed.src
Test for the wood type using if or case statements. Then apply the mods accordingly. Here is a small piece of my code that does that:

Code:
   if (wood == UOBJ_LOGS)
      return;
   elseif (wood == UOBJ_WOOD_OAK)
      bow.maxhp_mod := bow.maxhp_mod + 120;
      bow.hp := bow.maxhp_mod;
      bow.quality := bow.quality - 0.3;
      bow.dmg_mod := bow.dmg_mod - 3;
      bow.color := 0x002c; // Set to your colour for oak logs
      SetName(bow, ("an oaken " + tname) );


As I said that is an example and not a fully working script. Hopefully using that you can see how mods are made and build your own sections in the appropriate scripts.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl