I can't seem to get this working, can anyone see where I'm going wrong?
function loggingAxeProjectile::onCollision(%data, %player, %col, %fade, %pos, %normal)
{
if(%col.getdatablock().uiName$="Pine_Tree")
{
messageClient(%player.client,'ClientMsg',"\c6Chop successfully registered!");
if(%col.health$=""){%col.health=5;}
switch$(%player.getMountedImage(0).getName())
{
case "BronzeAxeImage":
%damage = 1;
case "IronAxeImage":
%damage = 2;
case "SteelAxeImage":
%damage = 3;
case "GoldAxeImage":
%damage = 5;
}
%col.health -= %damage;
messageClient(%player.client,'ClientMsg',"\c6"@ %col.health);
if(%col.health<1)
{
%col.killBrick();
%plantlocation = %col.getTransform();
schedule(3000,0,PlantNewTree,%plantlocation); //3000 for testing, raise to 60000
}
}
}
What happens is it messages 5 as the bricks health, every time the projectile hits. So the damage isn't being subtracted? But I have no idea why.
Also, is scheduling the planting of new bricks an okay way to do this? Or should I store all the position datas and plant them all at once in a tick to save processing lots of schedules?