Author Topic: BrickCollision  (Read 1618 times)

I am making a Resource mod but for some reason when I hit the tree or rock with the hammer it break's like normal any Ideas. At first I thought brick collision changed but now I have no idea.


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.setRendering(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.client.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;
}
}
}
else
{
Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
}

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

//Status
function serverCmdWoodStatus(%client)
{
if($woodon == 1)
{
messageClient(%client,'','\c2Wood is on!',$Woodon);
}
else 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

YAY WOODCUTTING :D
Someone has done a woodcutting mod before you should see if they still have it. I can't remember who it was.

Might it be something in the hammer thats causing this?
Also, a suggestion is to use something else to cut the wood, maybe make your own axe? :D

I am going to make a Axe. And the hammer is blocked from hammering the tree in a line of code.

Try brickPineTreeData... unless you've made a custom brick, that should be it.

Wow falcon.......First thing in script...

Code: [Select]
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";
};

Hey, I looked it over from the bottom up  :cookieMonster:

In that case I have no clue


Tools are no longer using projectiles, they all use raycasts. You should run a trace() then hit a brick and see what methods are called.

Ah I see thank's :D wonder why he doesn't use projectiles any more.

Tools are no longer using projectiles, they all use raycasts. You should run a trace() then hit a brick and see what methods are called.

Got it before I did.

Ah I see thank's :D wonder why he doesn't use projectiles any more.

Probably due to the new wrench options or brick handling changes.

Ah I see well I tried it and all it did was place about 5-6 empty spot's in my Console

Sorry for double post but
Tools are no longer using projectiles, they all use raycasts. You should run a trace() then hit a brick and see what methods are called.
Would a weapon such as a sword use projectiles still.

Sorry for double post butWould a weapon such as a sword use projectiles still.

Yep. My RP modification uses the sword as a parent for the axe and pickaxe.

Edit: Stop reading my edits.
« Last Edit: August 21, 2008, 03:30:23 PM by Dyed Brownie »

I am makin a axe I just used it as a test and it worked