Author Topic: Infinite Mining  (Read 792 times)

I have the script i edited... BUT It woudnt let me upgrade the pick anymore! I edited the price, Minerals, YOU NAME IT. But theres a Prob... i cant find my new minerals...

My script:
Code: [Select]
$Dig_pickCost[1] = 50;
$Dig_pickCost[2] = 50;
$Dig_pickCost[3] = 50;
$Dig_pickCost[4] = 50;
$Dig_pickCost[5] = 50;
$Dig_pickCost[6] = 100;
$Dig_pickCost[7] = 100;
$Dig_pickCost[8] = 100;
$Dig_pickCost[9] = 100;
$Dig_pickCost[10] = 100;
$Dig_pickCost[12] = 500;
$Dig_pickCost[13] = 500;
$Dig_pickCost[14] = 500;
$Dig_pickCost[15] = 500;
$Dig_pickCost[16] = 500;
$Dig_pickCost[17] = 500;
$Dig_pickCost[18] = 500;
$Dig_pickCost[19] = 500;
$Dig_pickCost[20] = 500;
$Dig_pickCost[21] = 500;
$Dig_pickCost[22] = 500;
$Dig_pickCost[23] = 500;
$Dig_pickCost[24] = 500;
$Dig_pickCost[25] = 500;
$Dig_pickCost[26] = 500;
$Dig_pickCost[27] = 500;
$Dig_pickCost[28] = 500;
$Dig_pickCost[29] = 500;
$Dig_pickCost[30] = 500;

$Dig_PickaxeColor = "0.000000 0.000000 0.900000 1.000000";

$Dig_NumOres=4;
$Dig_ore[0]="Dirt";
$Dig_ore[1]="Lava";
$Dig_Ore[2]="Gold";
$Dig_Ore[3]="Einsteinium";
$Dig_Ore[4]="Silver";
$Dig_Ore[5]="Caniz";
$Dig_Ore[6]="Frazaar";
$Dig_Ore[7]="Diamond";
$Dig_Ore[8]="Looon Sark";
$Dig_Ore[9]="Juksemaker pipe lort =P";
$Dig_Ore[10]="Caniz";
$Dig_Ore[11]="Particle Sorund";

$Dig_valueMin[0] = 0;
$Dig_valueMin[1] = 1;
$Dig_valueMin[2] = 100;
$Dig_valueMin[3] = 30;
$Dig_valueMin[4] = 30;
$Dig_valueMin[5] = 50;
$Dig_valueMin[6] = 200;
$Dig_valueMin[7] = 500;
$Dig_valueMin[8] = 400;
$Dig_valueMin[9] = 0;
$Dig_valueMin[10] = 200;
$Dig_valueMin[11] = 1000;

$Dig_Colors[0]=" ";
$Dig_Colors[1]="<color:FFFFFF>";
$Dig_Colors[2]="<color:FFFF00>";
$Dig_Colors[3]="<color:EEE5dE>";
$Dig_Colors[4]="<color:236B8E>";
$Dig_Colors[5]="<color:FAFAFA>";
$Dig_Colors[6]="<color:000000>";
$Dig_Colors[7]="<color:8C8C8C>";
$Dig_Colors[8]="<color:636F57>";
$Dig_Colors[9]="<color:008B00>";
$Dig_Colors[10]="<color:3299CC>";
$Dig_Colors[11]="<color:E3170D>";

$Dig_LowPercent[0] =0;
$Dig_HighPercent[0]=87.5;
$Dig_LowPercent[1] =89.5;
$Dig_HighPercent[1]=90;
$Dig_LowPercent[2] =97.5;
$Dig_HighPercent[2]=100;
$Dig_LowPercent[3] =87.5;
$Dig_HighPercent[3]=89.5;
$Dig_LowPercent[4] =50;
$Dig_HighPercent[4]=70;
$Dig_LowPercent[5]=20;
$Dig_HighPercent[5]=70;
$Dig_LowPercent[6]=30;
$Dig_HighPercent[6]=70;
$Dig_LowPercent[7]=30;
$Dig_HighPercent[7]=40;
$Dig_LowPercent[8]=20;
$Dig_HighPercent[8]=70;
$Dig_LowPercent[9]=10;
$Dig_HighPercent[9]=70;
$Dig_LowPercent[10]=8;
$Dig_HighPercent[10]=70;
$Dig_LowPercent[11]=0.5;
$Dig_HighPercent[11]=10;

$Dig_Health[0]=10;
$Dig_Health[1]=1;
$Dig_Health[2]=25*3;
$Dig_Health[3]=11*3;
$Dig_Health[4]=15*3;
$Dig_Health[5]=30;
$Dig_Health[6]=200;
$Dig_Health[7]=999;
$Dig_Health[8]=1000;
$Dig_Health[9]=200;
$Dig_Health[10]=9999;
$Dig_Health[11]=99999999999;

$Dig_Color[0]=8;
$Dig_Color[1]=0;
$Dig_Color[2]=1;
$Dig_Color[3]=13;
$Dig_Color[5]=14;
$Dig_Color[6]=19;
$Dig_Color[7]=5;
$Dig_Color[8]=2;
$Dig_Color[9]=9;
$Dig_Color[10]=24;
$Dig_Color[11]=25;

deactivatePackage(Dig_package);

function servercmdstartDig(%client)
{
    if(%client.bl_id != getNumKeyID() && findLocalClient() !$= %client)
    {
        messageClient(%client, '', "You are not the host so you cannot start dig mode");
        return;
    }

    $Dig_allowedMission["Slate"] = 1;
    $Dig_allowedMission["Slate Aurora"] = 1;
    $Dig_allowedMission["Destruct"] = 1;
    $Dig_groundID["Slate"] = 5;
    $Dig_groundID["Slate Aurora"] = 6;
    $Dig_groundID["Destruct"] = 5;

    if(!$Dig_allowedMission[missionInfo.name])
    {
        messageClient(%client, '', "Dig mode is only usable in Slate, Slate Aurora, and Destruct");
        return;
    }

    $Dig_host = %client;
    $Dig_host_brickgroup = %client.brickgroup;
    $Dig_host_id = %client.bl_id;
    deleteVariables("$Dig_placedDirt*");
    %ground = missionGroup.getobject($Dig_groundID[missionInfo.name]);
    if(missionInfo.name $= "Slate Aurora")
        %water = missionGroup.getobject(7);

    if(isObject(%ground))
        %ground.delete();

    if(isObject(%water))
        %water.delete();

    %spawnsphere = playerDropPoints.getobject(0);
    %spawnsphere.radius = 5;
    %spawnsphere.RayHeight = 3;

    messageAll('', "<color:00FF00>Dig mode is now enabled");

    for(%x = -5.5; %x <= 5.5; %x++)
        for(%y = -5.5; %y <= 5.5; %y++)
        {
           Dig_PlaceCement(%x*2 SPC %y*2 SPC 0, "brick4xCubeData");
           Dig_PlaceCement(%x*2 SPC %y*2 SPC 10, "brick4xCubeData");
        }

    %pos[0] = "10 10";
    %pos[1] = "10 -10";
    %pos[2] = "-10 10";
    %pos[3] = "-10 -10";

    for(%a = 0; %a < 4; %a++)
    {
        Dig_PlaceCement(%pos[%a] SPC 3, "brick8xCubeData");
        Dig_PlaceCement(%pos[%a] SPC 7, "brick8xCubeData");
    }

    for(%z = 0; %z <= 3; %z++)
    {
        for(%x = 0; %x < 8; %x++)
           Dig_PlaceDirt(-7 + %x*2 SPC 11 SPC 2+%z*2);

        for(%y = 0; %y < 8; %y++)
           Dig_PlaceDirt(11 SPC 7 - %y*2 SPC 2+%z*2);

        for(%x = 0; %x < 8; %x++)
           Dig_PlaceDirt(7 - %x*2 SPC -11 SPC 2+%z*2);

        for(%y = 0; %y < 8; %y++)
           Dig_PlaceDirt(-11 SPC -7 + %Y*2 SPC 2+%z*2);
    }

    %light = Dig_PlaceCement("0 0 8.75", "brick2x2FRoundData");
    %light.setLight(PlayerLight);

    activatepackage(Dig_spawnPackage);
    for(%c = 0; %c < ClientGroup.getCount(); %c++)
        if(ClientGroup.getObject(%c).hasSpawnedOnce)
           ClientGroup.getObject(%c).instantRespawn();

    Dig_announceStats();
    $Dig_on = 1;
}

function servercmdStopDig(%client)
{
    if(%client.bl_id != getNumKeyID() && findLocalClient() !$= %client)
    {
        messageClient(%client, '', "You are not the host so you cannot stop dig mode");
        return;
    }

    servercmdclearallbricks(%client);
    cancel($Dig_announceSchedule);
    messageAll('', "<color:00FF00>Dig mode is off");
    Dig_changeMapTry();
}

function Dig_changeMapTry()
{
    $Dig_changeMapSchedule = schedule(1000, 0, Dig_changeMapTry);
    if($server::BrickCount == 0)
    {
        deactivatepackage(Dig_spawnPackage);
        schedule(1000, 0, changeMap, missionInfo.name);
        cancel($Dig_changeMapSchedule);
        $Dig_on = 0;
    }
}

function serverCmdStats(%client)
 {
  for ( %x=0; %x < $Dig_NumOres; %x++)
    {
     messageClient(%client, '', "<color:FFFFFF>" @ $Dig_Ore[%x] SPC %client.dig_[%x] );
    }
  messageClient(%client, '', "<color:FFFFFF>pick level: " @ %client.PickAxeNum);
 }

function Dig_announceStats()
  {
    for (%c = 0; %c < ClientGroup.getCount(); %c++)
     {
      %client = ClientGroup.getObject(%c);

      for ( %x=0; %x <= $Dig_NumOres; %x++)
        {
         %count[%x] = %client.dig_[%x];
         if ( %client.dig_[%x] > %highCount[%x])
           {
            %highClient[%x] = %client;
            %highCount[%x] = %client.dig_[%x];
           }
        }
     }

    if (ClientGroup.getCount())
      {
       for ( %x=0; %x < $Dig_NumOres; %x++)
         {
          if ( %highClient[%x])
            {
             schedule(0,0, BottomPrintAll, "Most " @ $Dig_Ore[%x] @ " <color:FFFFFF>"@ %highClient[%x].getPlayerName() @"<color:FF0000>("@ %highClient[%x].dig_[%x] @")", 5);
            }
         }
       $Dig_announceSchedule = schedule(30000, 0, "Dig_announceStats");
    }
}

function servercmdPowerMode(%client)
{
    if(!%client.isAdmin)
        return;

    if(%client.dig_powermode)
    {
        messageClient(%client, '', "Power mode is now off");
        %client.dig_powermode = 0;
    }

    else
    {
        messageClient(%client, '', "Power mode is now on");
        %client.dig_powermode = 1;
    }
}

function Dig_PlaceCement(%pos, %db)
{
    %brick = new fxDTSBrick()
    {
        client = $Dig_host;
        datablock = %db;
        position = %pos;
        rotation = "0 0 0 0";
        colorID = 6;
        scale = "1 1 1";
        angleID = "0";
        colorfxID = "0";
        shapefxID = "0";
        isPlanted = 1;
        stackBL_ID = $Dig_host_id;
    };
    $Dig_host_brickgroup.add(%brick);

    if(mAbs(getWord(%pos, 0)) == 5 && mAbs(getWord(%pos, 1)) == 5 && getWord(%pos, 2) == 0)
        %brick.setItem("DiggingPickaxeItem");

    $server::BrickCount++;
    return %brick;
}

function Dig_PlaceDirt(%pos)
{
    %x = getWord(%pos, 0);
    %y = getWord(%pos, 1);
    %z = getWord(%pos, 2);
    %type = 0;   // dirt is ore #0
    %color = $Dig_Color[%type];
    %colorfx = 0;
    %health = $Dig_Health[%type];


    if (!(mAbs(%x) <= 11 && mAbs(%y) <= 11 && %z <= 10 && %z >= 0))
      {
       %random = getRandom() * 100;
       for ( %x=0; %x <= $Dig_NumOres; %x++)
         {
          if ( (%random <= $Dig_HighPercent[%x]) && (%random >= $Dig_LowPercent[%x]) )
            {
             %type = %x;
             %health=$Dig_health[%x];
             %color=$Dig_Color[%x];
            }
         }
      }
    if ( $Dig_Ore[%type] $= "lava")
      {
       %colorfx=3;
      }

    %brick = new fxDTSBrick()
    {
        client = $Dig_host;
        datablock = "brick4xCubeData";
        position = %pos;
        rotation = "0 0 0 0";
        colorID = %color;
        scale = "1 1 1";
        angleID = 0;
        colorfxID = %colorfx;
        shapefxID = 0;
        isPlanted = 1;
        stackBL_ID = $Dig_host_id;
        type = %type;
        isMineable = 1;
        health = %health;
    };

    $Dig_host_brickgroup.add(%brick);
    $Dig_placedDirt[%pos] = 1;
    $server::BrickCount++;
    return %brick;
}


function Dig_rebuildDirt(%position)
{
    %x = getWord(%position, 0);
    %y = getWord(%position, 1);
    %z = getWord(%position, 2);
    %position[0] = %x+2 SPC %y SPC %z;
    %position[1] = %x-2 SPC %y SPC %z;
    %position[2] = %x SPC %y+2 SPC %z;
    %position[3] = %x SPC %y-2 SPC %z;
    %position[4] = %x SPC %y SPC %z+2;
    %position[5] = %x SPC %y SPC %z-2;


    for(%a = 0; %a < 6; %a++)
    {
        %x = getWord(%position[%a], 0);
        %y = getWord(%position[%a], 1);
        %z = getWord(%position[%a], 2);
        if(!$Dig_placedDirt[%position[%a]] && !(mAbs(%x) <= 11 && mAbs(%y) <= 11 && %z <= 10 && %z >= 0))
           Dig_PlaceDirt(%position[%a]);
    }
}

function Dig_mineBrick(%obj, %col, %pos)
   {
    if (%col.isMineable)
      {
        serverPlay3D(hammerHitSound, %pos);

        if (%obj.client.pickaxeNum)
           %col.health -= 1*%obj.client.pickaxeNum;
        else
           %col.health--;

        if (%col.health <= 0 || (%obj.client.isAdmin && %obj.client.dig_powermode))
          {
           if (!%obj.client.dig_powermode)
             {
              %obj.client.mineMoney += $Dig_valueMin[%col.type];
              %obj.client.dig_[ %col.type ]++;
             }
           else
             {
              %obj.client.dig_dirt++;
             }
           %type = $Dig_Colors[%col.type] @ $Dig_Ore[%col.type];

           // special handling for Lava
           if (%col.type $= "lava")
             {
              if (!%obj.client.isAdmin)
                %obj.client.player.kill();

              messageAll('', "<color:FFFFFF>"@ %obj.client.getPlayerName() @" <color:00FF00>mined a lava pocket!");
             }


           commandToClient(%obj.client, 'centerPrint', "Mined "@ %type, 5);
           %obj.client.sendMiningStatus();
           Dig_rebuildDirt(%col.getPosition());
           %col.delete();
          }
        else
          commandToClient(%obj.client, 'centerPrint', "Health: <color:FFFFFF>"@ %col.health, 3);
      }
   }

function serverCmdUpgradePick(%client)
{
    if(%client.pickaxeNum > 4)
        messageClient(%client, '', "You cannot upgrade your pick above level 5");

    else if($Dig_pickCost[%client.pickaxeNum+1] > %client.mineMoney)
        messageClient(%client, '', "You do not have enough money. Money needed: $"@ mAbs(%client.mineMoney - $Dig_pickCost[%client.pickaxeNum+1]));

    else if($Dig_pickCost[%client.pickaxeNum+1] <= %client.mineMoney)
    {
        %client.pickaxeNum++;
        %client.mineMoney -= $Dig_pickCost[%client.pickaxeNum];
        messageClient(%client, '', "You have upgrade your pick to level "@ %client.pickaxeNum @"($"@ $Dig_pickCost[%client.pickaxeNum] @")");
    }

    %client.sendMiningStatus();
}


function serverCmdBuyLight(%client)
{
    if(%client.mineLight)
        commandToClient(%client, 'centerPrint', "You already bought a light!", 3);

    else if(%client.mineMoney >= 25)
    {
        %client.mineLight = 1;
        commandToClient(%client, 'centerPrint', "You have bought a light for \c3$25", 3);
        %client.mineMoney -= 25;
        serverCmdLight(%client);
    }

    else
        commandToClient(%client, 'centerPrint', "You cannot afford a light for \c3$25", 3);
    %client.sendMiningStatus();
}

function DiggingPickaxeProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
    Dig_mineBrick(%obj, %col, %pos);
}

function gunProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{

    parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
    if(%obj.client.isAdmin)
        Dig_mineBrick(%obj, %col, %pos);
}

function akimboGunProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
    parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
    if(%obj.client.isAdmin)
        Dig_mineBrick(%obj, %col, %pos);
}



datablock projectileData(DiggingPickaxeProjectile : hammerProjectile)
{
    directDamage = 5;
    lifeTime = 100;
    explodeOnDeath = false;
};

datablock itemData(DiggingPickaxeItem : hammerItem)
{
    uiName = "Pickaxe";
    image = DiggingPickaxeImage;
    colorShiftColor = $Dig_PickaxeColor;
};

datablock shapeBaseImageData(DiggingPickaxeImage : hammerImage)
{
    item = DiggingPickaxeItem;
    projectile = DiggingPickaxeProjectile;
    colorShiftColor = $Dig_PickaxeColor;
};

function DiggingPickaxeImage::onFire(%this, %obj, %slot)
{
    parent::onFire(%this, %obj, %slot);
    %obj.playThread(2, "armAttack");
}

function DiggingPickaxeImage::onStopFire(%this, %obj, %slot)
{
    %obj.playThread(2, "root");
}

package Dig_package
{
    function GameConnection::spawnPlayer(%this)
    {
        parent::spawnPlayer(%this);
    }

    function GameConnection::sendMiningStatus(%this)
    {
        if(!%this.pickaxeNum)
           %this.pickaxeNum = 0;


        if(!%this.mineMoney)
           %this.mineMoney = 0;

        %msg = "<font:arial bold:14>\c6Cash: \c3$"@ %this.mineMoney @"     \c6Dirt: \c3"@ %this.dig_dirt @"     \c6Pickaxe level: \c3"@ %this.pickaxeNum;

        if(%client.pickaxeNum < 5)
           %msg = %msg @"     \c6Next pickaxe: \c3$"@ $Dig_pickCost[%this.pickaxeNum+1];

        commandtoClient(%this, 'bottomPrint', %msg, 10);
    }

    function GameConnection::saveMiningStats(%this)
    {
        %id = %this.bl_id;
        $Dig_stats_isSaved[%id] = 1;
        $Dig_stats_pickaxeNum[%id] = %this.pickaxeNum;
        $Dig_stats_mineMoney[%id] = %this.mineMoney;
        for ( %x=0; %x <= $Dig_NumOres; %x++)
          {
           $Dig_stats_dig_[%x]= %this.dig_[%x];
          }
    }

    function GameConnection::loadMiningStats(%this)
      {
        %id = %this.bl_id;
        if($Dig_stats_isSaved[%id])
           return 0;

        %this.pickaxeNum = $Dig_stats_pickaxeNum[%id];
        %this.mineMoney = $Dig_stats_mineMoney[%id];
        for ( %x=0; %x <= $Dig_NumOres; %x++)
          {
           %this.dig_[%x] = $Dig_stats_dig_[%x];
          }
        return 1;
    }

    function GameConnection::autoAdminCheck(%this)
    {
        %parent = parent::autoAdminCheck(%this);
        if (!%this.loadMiningStats())
          {
           %this.pickaxeNum = 1;
           %this.mineMoney = 0;
           for ( %x=0; %x <= $Dig_NumOres; %x++)
            {
             %this.dig_[%x] = 0;
            }
        }
        return %parent;
    }

    function GameConnection::onClientLeaveGame(%this)
    {
        %this.saveMiningStats();
        parent::onClientLeaveGame(%this);
    }


    function serverCmdLight(%client)
    {
        if(%client.mineLight || !$Dig_on)
           parent::serverCmdLight(%client);

        else
           commandToClient(%client, 'centerPrint', "You have not bought a light yet. You can by a light for \c3$25", 3);
    }

};
activatePackage(Dig_package);

Please help!

Yes... NO first post for you guys!
But HELP!

I think when you define the percent values, each mineral needs to have its own range. (none of them overlap)

Although I'm not sure.

Technos check your PMs.

Wow! Thanks, Topic Locked!

I found the prob too...
I fixed...