Author Topic: On Brick Hit If Projectile  (Read 2944 times)

You might also want to package

function FxDtsBrick::onPlant(%this,%stuff...)

and inside somewhere call

%this.health = %this.getDataBlock().defaultHealth;
You still have the %col.getDatablock().Health things inside the if checks.
Ok, so this is my(still not working) code:
Code: [Select]
//=========================================================================
// Skill_Mining Confirm
//=========================================================================
//This confirms to Skill_Core that for have Skill_Mining enabled.
$Skill::Mining = 1;
//=========================================================================
// Executions
//=========================================================================
// Misc
exec("./Tool_Pickaxe.cs");
// Ore
exec("./Ore/Copper.cs");
exec("./Ore/Tin.cs");
exec("./Ore/Iron.cs");
exec("./Ore/Coal.cs");
exec("./Ore/Gold.cs");
//=========================================================================
// Ore functions
//=========================================================================
package skillMining {

function SkillPickaxeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getClassName() !$= "fxDtsBrick")
{
parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);

if(%col.getDataBlock().isOre)
{
if(%col.getDatablock().Health >= 1)
{
%col.health -= getRandom(1,5);
commandToClient(%this,'centerPrint',"\c6You swing your pick at the ore.",3);
}

else if(%col.getDatablock().Health < 1)
{
%col.Health = %col.getDataBlock().defaultHealth;
%col.Disappear(%col.getDatablock().regrowTime);
%this.Resources +=  %col.getDataBlock().oreAmount;

messageClient(%this,'',"\c3You have mined some \c6" @ %col.getDataBlock().oreName @ "\c3.");
}
}
}

else
{
parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
}


function fxDTSBrick::onPlant(%data, %obj)
{
if(%obj.getDatablock().isOre == 1)
{
Parent::onPlant(%data, %obj);

%obj.Health = %obj.getDatablock().defaultHealth;
}

else
{
Parent::onPlant(%data, %obj);
}
}

}; activatePackage(skillMining);
could changing SkillPickaxeProjectile::onCollision to fxDTSBrick::onCollision and have it check the projectile work?

could changing SkillPickaxeProjectile::onCollision to fxDTSBrick::onCollision and have it check the projectile work?

Yeah.

Ok, fixed it up for you once again.. lol.

Code: [Select]
//=========================================================================
// Skill_Mining Confirm
//=========================================================================
//This confirms to Skill_Core that for have Skill_Mining enabled.
$Skill::Mining = 1;
//=========================================================================
// Executions
//=========================================================================
// Misc
exec("./Tool_Pickaxe.cs");
// Ore
exec("./Ore/Copper.cs");
exec("./Ore/Tin.cs");
exec("./Ore/Iron.cs");
exec("./Ore/Coal.cs");
exec("./Ore/Gold.cs");
//=========================================================================
// Ore functions
//=========================================================================
package skillMining {

function SkillPickaxeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
//if(%col.getClassName() !$= "fxDtsBrick") should be
if(%col.getClassName() $= "fxDtsBrick")
{
parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);

if(%col.getDataBlock().isOre)
{
//if(%col.getDatablock().Health >= 1) should be
if(%col.Health >= 1)
{
%col.health -= getRandom(1,5);
commandToClient(%this,'centerPrint',"\c6You swing your pick at the ore.",3);
}
//else if(%col.getDatablock().Health < 1) should be
else if(%col.Health < 1)
{
%col.Health = %col.getDataBlock().defaultHealth;
%col.Disappear(%col.getDatablock().regrowTime);
%this.Resources +=  %col.getDataBlock().oreAmount;

messageClient(%this,'',"\c3You have mined some \c6" @ %col.getDataBlock().oreName @ "\c3.");
}
}
}
parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}


function fxDTSBrick::onPlant(%brick, %somethingelsewedontneed)
{
Parent::onPlant(%brick, %somethingelsewedontneed);

if(%brick.getDatablock().isOre == 1)
{
%obj.Health = %obj.getDatablock().defaultHealth;
}
}

}; activatePackage(skillMining);

Yeah.

Ok, fixed it up for you once again.. lol.

-Awesome code-
Much progress!

Only thing I can't figure out is the following:
  • Why it does not show the centerprint
  • Why it does not add the resources to the client after it is mined

Much progress!

Only thing I can't figure out is the following:
  • Why it does not show the centerprint
  • Why it does not add the resources to the client after it is mined

Thanks.

Ok, actually look at your code please, notice you have

commandToClient(%this,'centerPrint',"\c6You swing your pick at the ore.",3);

and

messageClient(%this,'',"\c3You have mined some \c6" @ %col.getDataBlock().oreName @ "\c3.");

and a couple other things that use %this.

now look at this

SkillPickaxeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)

%this is your skillpickaxeprojectile, which isn't a client, yikes!

try instead the following, %client = %obj.client; and also under that do

echo("Client object name => "@%client.name);

to see if i'm correct, which i think i am.