Woodcutting Mod

Author Topic: Woodcutting Mod  (Read 2034 times)

I've gotten permission from Kunit to post this.
Quote from: "Kunit_Yo" In PM
if you want to post it saying Kunit wants help or w/e

Why wont this work in V9
Code: [Select]

//////////////////////////
//Kunits Woodcutting   //
//////////////////////////

//RPGbrick's

datablock fxDTSBrickData (brickTreeData){
   brickFile = "base/data/bricks/special/pineTree.blb";
   category = "Special";
   subCategory = "RPG";
   uiName = "RPGtree";
   iconName = "add-ons/brickIcons/pinetree";
   collisionShapeName = "base/data/shapes/bricks/pinetree.dts";
};

//WoodCutting////////////////////////////////////////////////////////////////////

function regrow(%brick){//recreate the brick
     %brick.setcolor(%brick.realcolor);
        %brick.setcolliding(1);
      %brick.setraycasting(1);
}

package Wood
{
       function hammerProjectile::oncollision(%this,%obj,%col,%fade,%pos,%normal)
    {
        if(!isobject(%col)){return;}
        if(%col.getDatablock() $= nametoid("brickTreeData"))
        {
            %col.hits++;//amount of hits taken plus 1
            if(%col.hits>=25){//10 hits
             %random = getRandom(1,150);
      if(%random >= 1 && %random <= 40)
{
%obj.cleint.quantity["MapleWood"]+=1;
%obj.client.WCE+=getrandom(1,80);
messageClient(%obj.client, '', '\c2You gained One Maplewood!',%ammount);
}
else if(%random >= 50 && %random <= 80)
{
%obj.client.quantity["OakWood"]+=1;
%obj.client.WCE+=getrandom(1,40);
messageClient(%obj.client, '', '\c2You gained One Oakwood!',%ammount);
}
else if(%random >= 80 && %random <= 100)
{
%obj.client.quantity["PineWood"]+=1;
%obj.client.WCE+=getrandom(1,80);
messageClient(%obj.client, '', '\c2You gained One Pinewood!',%ammount);
}
else if(%random >= 80 && %random <= 150)
{
messageClient(%obj.client, '', '\c2That wood is rotten!',%ammount);
}         
             %col.realcolor = %col.getColorID();
             %col.setcolor(63);
             %col.setcolliding(0);
             %col.setraycasting(0);
             %col.hits=0;
             %col.sched = schedule(15000,0,regrow,%col);
         return;
        }else{return;}
        }
        Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);

    }

function serverCmdplantbrick(%client)
{     
   if($woodon == 0)
        {     
      Parent::ServerCmdplantbrick(%client);
      return;
   }
   if(%client.isSuperAdmin)
        {     
      Parent::ServerCmdplantbrick(%client);
      return;
   }     
   if($woodon == 1 && %client.quantity["PineWood"] < 1 && %client.quantity["OakWood"] < 1 && %client.quantity["MapleWood"] < 1 )
   {
      messageClient(%client,'','Not enough wood!');
      return;
   }
   if(%client.quantity["PineWood"] > 0)
   {
      %client.quantity["PineWood"]--;
      Parent::ServerCmdplantbrick(%client);
      return;
   }
   if(%client.quantity["OakWood"] > 0)
   {
      %client.quantity["OakWood"]--;
      Parent::ServerCmdplantbrick(%client);
      return;
   }
   if(%client.quantity["MapleWood"] > 0)
   {
      %client.quantity["MapleWood"]--;
      Parent::ServerCmdplantbrick(%client);     
      return;
   }
}
};
ActivatePackage(Wood);

//Cmd's

function ServerCmdcheckWood(%client)
   {
      if(%client.quantity["Pinewood"] <= 0)
      %client.quantityPinewood = 0;
      if(%client.quantity["Oakwood"] <= 0)
      %client.quantity["Oakwood"] = 0;
      if(%client.quantity["Maplewood"] <= 0)
      %client.quantity["Maplewood"] = 0;
      bottomprint(%client, "\c2PineWood: \c1" @ %client.quantity["Pinewood"] @"     \c2MapleWood: \c1" @ %client.quantity["Maplewood"] NL "\c2OakWood: \c1" @ %client.quantity["Oakwood"],5,3);
   
}

//Saving

package Savez
{
   function GameConnection::onClientEnterGame(%this)
   {
      Parent::onClientEnterGame(%this);
      exec("Add-ons/WoodCutting/" @ %this.bl_id @ ".WoodData");
      %this.RPG["ISSPAWNED"] = 1;
   }
   function Savez(%Client)
   {
      if(%client.RPG["ISSPAWNED"] == 0)
         return;
      %file = new FileObject();
      %file.openforwrite("Add-ons/Woodcutting/" @ %client.bl_id @ ".WoodData");

      if(%client.quantity["OakWood"] == 0)
         %client.quantity["OakWood"] = 0;         
      %file.writeline("findclientbybl_id(" @  %client.bl_id @ ").quantity[\"OakWood\"] = " @ %client.quantity["OakWood"] @ ";");
     
      if(%client.quantity["PineWood"] == 0)
         %client.quantity["PineWood"] = 0;         
      %file.writeline("findclientbybl_id(" @  %client.bl_id @ ").quantity[\"PineWood\"] = " @ %client.quantity["PineWood"] @ ";");

      if(%client.quantity["MapleWood"] == 0)
         %client.quantity["MapleWood"] = 0;     
      %file.writeline("findclientbybl_id(" @  %client.bl_id @ ").quantity[\"MapleWood\"] = " @ %client.quantity["MapleWood"] @ ";");

      %file.close();
      %file.delete();
   }
   function autoSavez()
   {
      for(%x=0; %x < clientgroup.getcount(); %x++)
      {
         Savez(clientgroup.getobject(%x));
      }
      schedule(60000,0,autoSavez);
   }
};
activatePackage("Savez");
schedule(60000,0,autoSavez);

//Status
function serverCmdWoodStatus(%client)
    {
       if($woodon == 1)
   {
             messageClient(%client,'','\c2Wood is on!',$Woodon);
   }
   if($woodon == 0)
   {
   messageClient(%client,'','\c3Wood is off!',$Woodon);
   }
}
//End
//WoodOn
function serverCmdWoodOn(%client)
    {
   $woodon = 1;         
   messageClient(%client,'','\c2Wood is now On!',$Woodon);
}
//End
//WoodOff
function serverCmdWoodOff(%client)
    {
       $woodon = 0;
       messageClient(%client,'','\c3Wood is now Off!',$Woodon);
}   
//End
function WCLvl()
{
   for(%c = 0; %c < ClientGroup.getcount(); %c++)
   {
      %client = ClientGroup.getobject(%c);
      if(%client.WCE > 0)
         %client.WCL = 1;
      if(%client.WCE > 200)
         %client.WCL = 2;
      if(%client.WCE > 300)
         %client.WCL = 3;
      if(%client.WCE > 400)
         %client.WCL = 4;
      if(%client.WCE > 500)
         %client.WCL = 5;
      if(%client.WCE > 600)
         %client.WCL = 6;
      if(%client.WCE > 700)
         %client.WCL = 7;
      if(%client.WCE > 800)
         %client.WCL = 8;
      if(%client.WCE > 900)
         %client.WCL = 9;
      if(%client.WCE > 1000)
         %client.WCL = 10;
      if(%client.WCE > 1100)
         %client.WCL = 11;
      if(%client.WCE > 1200)
         %client.WCL = 12;
      if(%client.WCE > 1300)
         %client.WCL = 13;
      if(%client.WCE > 1400)
         %client.WCL = 14;
      if(%client.WCE > 1500)
         %client.WCL = 15;
      if(%client.WCE > 1600)
         %client.WCL = 16;
      if(%client.WCE > 1700)
         %client.WCL = 17;
      if(%client.WCE > 1800)
         %client.WCL = 18;
      if(%client.WCE > 1900)
         %client.WCL = 19;
      if(%client.WCE > 2000)
         %client.WCL = 20;
      if(%client.WCE > 2100)
         %client.WCL = 21;
      if(%client.WCE > 2200)
         %client.WCL = 22;
      if(%client.WCE > 2300)
         %client.WCL = 23;
      if(%client.WCE > 2400)
         %client.WCL = 24;
      if(%client.WCE > 2500)
         %client.WCL = 25;
      if(%client.WCE > 2600)
         %client.WCL = 26;
      if(%client.WCE > 2700)
         %client.WCL = 27;
      if(%client.WCE > 2800)
         %client.WCL = 28;
      if(%client.WCE > 2900)
         %client.WCL = 29;
      if(%client.WCE > 3000)
         %client.WCL = 30;
      if(%client.WCE > 3100)
         %client.WCL = 31;
      if(%client.WCE > 3200)
         %client.WCL = 32;
      if(%client.WCE > 3300)
         %client.WCL = 33;
      if(%client.WCE > 3400)
         %client.WCL = 34;
      if(%client.WCE > 3500)
         %client.WCL = 35;
      if(%client.WCE > 3600)
         %client.WCL = 36;
      if(%client.WCE > 3700)
         %client.WCL = 37;
      if(%client.WCE > 3800)
         %client.WCL = 38;
      if(%client.WCE > 3900)
         %client.WCL = 39;
      if(%client.WCE > 4000)
         %client.WCL = 40;
      if(%client.WCE > 4100)
         %client.WCL = 41;
      if(%client.WCE > 4200)
         %client.WCL = 42;
      if(%client.WCE > 4300)
         %client.WCL = 43;
      if(%client.WCE > 4400)
         %client.WCL = 44;
      if(%client.WCE > 4500)
         %client.WCL = 45;
      if(%client.WCE > 4600)
         %client.WCL = 46;
      if(%client.WCE > 4700)
         %client.WCL = 47;
      if(%client.WCE > 4800)
         %client.WCL = 48;
      if(%client.WCE > 4900)
         %client.WCL = 49;
      if(%client.WCE > 5000)
         %client.WCL = 50;
   }
   schedule(1000,0,WClvl);
}
schedule(1000,0,WClvl);
//End
//Granting
function serverCmdGrantWood(%client,%victim,%amount)
{
    if(!%client.isSuperAdmin)
        return;
    %victim = findClientByBL_ID(%victim);
    if(!isobject(%victim)){return;}//dont let them give Gold to non-existant people
    %victim.quantity["Pinewood"]+=%amount;
    %victim.quantity["Oakwood"]+=%amount;
    %victim.quantity["Maplewood"]+=%amount;
   messageClient(%victim,'Given %1 by %2',%client.name,%amount);
}
//End
//Skill Checking
function serverCmdSkillCheckCutting(%client)
{
       messageClient(%client,'','\c2WoodCuttingLvl: \c1%1',%client.WCL);
}

function serverCmdExpCheckCutting(%client)
{
       messageClient(%client,'','\c2WoodCuttingExp: \c1%1',%client.WCE);
}
//End
« Last Edit: August 11, 2008, 06:09:24 PM by Green Link »

Wow, that is one stuffty leveling function, did it ever dawn on kunit to do this

Code: [Select]
if(%client.WCE>%client.WCL*100){
 %client.WCL++;
}

?


Also, why does it check your level every second instead of after you gain exp?



Eh, anyways, this isn't to criticize the script.
Or is it?

What the hell is this topic about?

Oh, I forgot to post the reason. This code wont work in V9.

Lol sht I posted my bad version. :p

:D post your good one below.



Why not take advantage of events and make oncut and onfell imput events and chopstep, gain exp and gain wood output events?  Just have the wood cutting tool call oncut when it hits a brick.

Very smart...:D I will try it here in a bit. Are brick's still fxDTSBrickData  or whatever it was.