Blockland Forums > Modification Help
On Brick Hit If Projectile
jes00:
--- Quote from: Superb on December 05, 2011, 11:04:13 PM ---You might also want to package
function FxDtsBrick::onPlant(%this,%stuff...)
and inside somewhere call
%this.health = %this.getDataBlock().defaultHealth;
--- End quote ---
--- Quote from: Destiny/Zack0Wack0 on December 05, 2011, 11:36:46 PM ---You still have the %col.getDatablock().Health things inside the if checks.
--- End quote ---
Ok, so this is my(still not working) code:
--- Code: ---//=========================================================================
// 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);
--- End code ---
could changing SkillPickaxeProjectile::onCollision to fxDTSBrick::onCollision and have it check the projectile work?
Superb:
--- Quote from: jes00 on December 06, 2011, 11:35:53 AM ---could changing SkillPickaxeProjectile::onCollision to fxDTSBrick::onCollision and have it check the projectile work?
--- End quote ---
Yeah.
Ok, fixed it up for you once again.. lol.
--- Code: ---//=========================================================================
// 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);
--- End code ---
jes00:
--- Quote from: Superb on December 06, 2011, 12:06:47 PM ---Yeah.
Ok, fixed it up for you once again.. lol.
-Awesome code-
--- End quote ---
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
Superb:
--- Quote from: jes00 on December 06, 2011, 12:52:58 PM ---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
--- End quote ---
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.
jes00:
--- Quote from: Superb on December 06, 2011, 01:56:41 PM ----Lots of stuff-
--- End quote ---
Thanks! *Topic Locked*