So I've been making an infinite mining mod based off of Red_Guy's Unlimited Mining add-on. I've worked out most of the bugs, but for some reason, I keep gorramn falling through the floor. I can't touch anything spawned by the /startdig command. /stopdig works just fine. The pickaxe "hits" the bricks, but it doesn't make a noise and doesn't do anything. In fact, whenever I spawn, I immediately fall through the spawn area into the inky blackness. I think the problem is in the placeCement() functions and whatnot that create the spawn area. Screenshot included, relevant code included, but my ores are omitted so you don't stealz them.
$Dig_PickaxeColor = "1.000000 0.500000 0.000000 1.000000";
$Dig_CementAxeColor = "0.000000 1.000000 0.100000 1.000000";
$Dig_lightCost=25;
$Dig_HeatSuitCost=200;
$Dig_CementColor=50;
$Dig_Data_DiscoveryColor=5;
$Dig_Data_DiscoveryPercent=10;
// need this here because the datablocks need PickaxeColor and CementAxeColor
exec("./miningDatablocks.cs");
$Dig_Data_NumOres=31;
$Dig_Data_Ore[0] ="Dirt"; // Dont change this one
$Dig_Data_Ore[1] ="Lava"; // Dont change this one
// Dirt types. %name %depth %health %colorStart %colorSize
$Dig_Data_NumDirt=16;
$Dig_Data_Dirt[0]= "Space" TAB "5000 1 52 1";
$Dig_Data_Dirt[1]= "Moon" TAB "2500 120 45 1";
$Dig_Data_Dirt[2]= "Space" TAB "1000 1 52 1";
$Dig_Data_Dirt[3]= "Sky" TAB "700 5 7 1";
$Dig_Data_Dirt[4]= "Grass" TAB "605 20 4 1";
$Dig_Data_Dirt[5]= "Ground" TAB "600 25 43 2";
$Dig_Data_Dirt[6]= "Sand" TAB "300 25 30 1";
$Dig_Data_Dirt[7]= "Loose Dirt" TAB "150 10 44 1";
$Dig_Data_Dirt[8]= "Dirt" TAB "25 10 54 4";
$Dig_Data_Dirt[9]= "Dense Dirt" TAB "-150 50 57 4";
$Dig_Data_Dirt[10]= "Rock" TAB "-300 100 46 3";
$Dig_Data_Dirt[11]= "Hard Rock" TAB "-600 200 49 1";
$Dig_Data_Dirt[12]= "Seriously Hard Rock" TAB "-900 400 50 1";
$Dig_Data_Dirt[13]= "Metal Rock" TAB "-1200 800 51 1";
$Dig_Data_Dirt[14]= "Hard Metal Rock" TAB "-1800 1600 51 1";
$Dig_Data_Dirt[15]= "Seriously Hard Metal Rock" TAB "-2400 3200 51 1";
$Dig_Data_Dirt[16]= "Core" TAB "-5000 32000 2 1";
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_allowedMission["DestructLight"] = 1;
$Dig_groundID["Slate"] = 5;
$Dig_groundID["Slate Aurora"] = 6;
$Dig_groundID["Destruct"] = 5;
$Dig_groundID["DestructLight"] = 5;
if (!$Dig_allowedMission[missionInfo.name])
{
messageClient(%client, '', "Dig mode is only usable in Slate, Slate Aurora, Destruct, and DestructLight");
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_package);
exec("config/server/MiningStats.cs");
exec("config/server/MiningData.cs");
// respawn the active players
for (%c = 0; %c < ClientGroup.getCount(); %c++)
if (ClientGroup.getObject(%c).hasSpawnedOnce)
ClientGroup.getObject(%c).instantRespawn();
$Dig_on = 1;
$Pref::Server::WelcomeMessage = "\\c2Welcome to Homfrog's Infinite Mining, %1 ! Type /help for information";
// load mining stats for all clients
for (%c = 0; %c < ClientGroup.getCount(); %c++)
{
%client = ClientGroup.getObject(%c);
%client.LoadMiningStats();
}
// Start auto-save timer
Dig_saveStats();
}
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);
cancel($Dig_StatsTimer);
messageAll('', "<color:00FF00>Dig mode is off");
$Pref::Server::WelcomeMessage="";
Dig_changeMapTry();
deactivatepackage(Dig_package);
export("$Dig_Data*", "config/server/miningData.cs");
Dig_ChangeMapTry();
}
function Dig_changeMapTry()
{
$Dig_changeMapSchedule = schedule(1000, 0, Dig_changeMapTry);
if ($server::BrickCount < 1)
{
deactivatepackage(Dig_spawnPackage);
schedule(1000, 0, changeMap, missionInfo.name);
cancel($Dig_changeMapSchedule);
$Dig_on = 0;
// clear all players bottomBrint stuff
for (%c = 0; %c < ClientGroup.getCount(); %c++)
{
%client = ClientGroup.getObject(%c);
commandtoClient(%client, 'bottomPrint', "", 1);
}
}
}
function serverCmdStats(%client)
{
for ( %x=0; %x < $Dig_Data_NumOres; %x++)
{
messageClient(%client, '', "<color:FFFFFF>" @ $Dig_Data_Ore[%x] SPC %client.dig_[%x] );
}
messageClient(%client, '', "<color:FFFFFF>pick level: " @ %client.PickAxeNum);
}
// not used - but left in the file incase somebody wants to turn it on
function Dig_announceStats()
{
for (%c = 0; %c < ClientGroup.getCount(); %c++)
{
%client = ClientGroup.getObject(%c);
for ( %x=0; %x <= $Dig_Data_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_Data_NumOres; %x++)
{
if ( %highClient[%x])
{
schedule(0,0, BottomPrintAll, "Most " @ $Dig_Data_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;
}
}
// place cement bricks for the spawn area
function Dig_PlaceCement(%pos, %db)
{
%brick = new fxDTSBrick()
{
client = $Dig_host;
datablock = %db;
position = %pos;
rotation = "0 0 0 0";
colorID = $Dig_CementColor;
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");
//%brick.setTrusted(1); // not a good idea - but left in just in case
$server::BrickCount++;
return %brick;
}
// place a 'dirt' brick. can be regular dirt, or an ore brick depending on random percent
function Dig_PlaceDirt(%pos)
{
%x = getWord(%pos, 0);
%y = getWord(%pos, 1);
%z = getWord(%pos, 2);
if (!(mAbs(%x) <= 11 && mAbs(%y) <= 11 && %z <= 10 && %z >= 0))
{
%type = -1;
%random = getRandom() * 100;
for ( %x=0; %x <= $Dig_Data_NumOres; %x++)
{
%low = getWord($Dig_Data_Percent[%x], 0);
%high = getWord($Dig_Data_Percent[%x], 1);
%depth = getWord($Dig_Data_Percent[%x], 2);
if ( %x==1 && %z < 0) // lava
{
//the deeper you go, the higher chance to find a lava brick.
%low -= mfloor(mabs(%z / 100));
}
// some ore is only available below a certian depth
if ( %depth==0)
{
%depth=%z; // depth 0 means available anywhere
}
if ( %depth < 0)
{
if ( %z <= %depth)
{
if ( (%random <= %high) && (%random >= %low) )
{
%type = %x;
}
}
}
else
{
if ( %z >= %depth)
{
if ( (%random <= %high) && (%random >= %low) )
{
%type = %x;
}
}
}
}
}
$Dig_placedDirt[%pos] = 1;
if ( %type == 0)
{
return setDirtBlock(%pos, %type);
}
return setOreBlock(%pos, %type);
}
// place a dirt block.
// adjust the color and health acording to what dirt types are defined
function setDirtBlock(%pos, %type)
{
%color = $Dig_Data_Color[%type];
%z = getWord(%pos, 2);
%dirtType=-1; %x=0;
while ( %dirtType == -1)
{
%rec = getField($Dig_Data_Dirt[%x], 1);
%depth = getWord(%rec, 0);
%rec1 = getField($Dig_Data_Dirt[%x+1], 1);
%depth1 = getWord(%rec1, 0);
if ( %x+1 > $Dig_Data_NumDirt)
{
%depth1= mFloor(%depth*2);
}
if ( %z >= %depth1 && %z <= %depth)
{
%dirtType=%x;
}
%x++;
}
//%rec = getField($Dig_Data_Dirt[%dirtType], 1);
%health = getWord(%rec, 1);
%color = getWord(%rec, 2);
%colorSize = getWord(%rec, 3);
if ( %colorSize > 1)
{
// adjust color depending on how far we are into the current layer of dirt
%currDepth = getWord(getField($Dig_Data_Dirt[%dirtType], 1), 0);
%diff = getWord(getField($Dig_Data_Dirt[%dirtType+1], 1), 0) - %currDepth;
%change = mabs(mFloor( ( (%z - %currDepth) / %diff)* %colorSize));
if ( %change > %colorSize)
{
%change=%colorSize;
}
%color += %change;
}
%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;
dirtType = %dirtType;
isMineable = 1;
health = %health;
};
$Dig_host_brickgroup.add(%brick);
$server::BrickCount++;
return %brick;
}
function DiggingPickaxeProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
Dig_mineBrick(%obj, %col, %pos);
}
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");
}
function DiggingCementImage::onHitObject(%this, %obj, %col, %brick, %pos, %normal)
{
Dig_DropCement(%obj, %brick, %pos, %normal);
}
// "hack" into the print gun's onFire code to use the cement placer
function DiggingCementImage::onFire(%this, %arga, %argb)
{
PrintGunImage::onFire(%this, %arga, %argb);
}