I made a script that gives bricks a health value. Shoot the bricks with a gun, and the health goes down. When a brick's health reaches 0, the brick is fake-killed, and then
deleted. Reload bricks if you want it back.
Currently it works for any default weapon, and also the complex weapons pack(The one I was using). I had to manually add in the complex weapons as they store their damage values in their damage function and it was faster to just add them than try to find some way of making the script figure it out.
Enjoy.
function fxDTSBrick::initHealth(%brick)
{
%boxMin = getWords(%brick.getWorldBox(), 0, 2);
%boxMax = getWords(%brick.getWorldBox(), 3, 5);
%boxDiff = vectorSub(%boxMax, %boxMin);
%health = mAbs(getWord(%boxDiff,0)*getWord(%boxDiff,1)*getWord(%boxDiff,2)*60);
if(%health<=3841)
{
%brick.health = %health;
}
}
if(isPackage(BrickHealthPackage))
{
deactivatepackage(BrickHealthPackage);
}
package BrickHealthPackage
{
function fxDTSBrick::onPlant(%brick)
{
%brick.initHealth();
Parent::onPlant(%brick);
}
function fxDTSBrick::onLoadPlant(%brick)
{
%brick.initHealth();
Parent::onLoadPlant(%brick);
}
function fxDTSBrick::onProjectileHit(%brick, %proj, %client)
{
if(isObject(%proj)&&%brick.health!$="")
{
if(!isObject(%proj.damageRef))
{
%dmg = %proj.getDatablock().directDamage;
%brick.health-=%dmg;
if(%brick.health<=0)
{
%brick.fakekillbrick(vectorscale(%proj.getVelocity(),0.05), 2);
%brick.schedule(1000,"delete");
}
}
else
{
switch$ (%proj.damageRef.getName())
{
case "ColtWalkerImage":
%dmg = 75;
case "Colt1911Image":
%dmg = 16;
case "M1GarandImage":
%dmg = 30;
case "M24RifleScopeImage":
%dmg = 90;
case "M24RifleImage":
%dmg = 90;
case "MicroUziImage":
%dmg = 10;
case "Remington870Image":
%dmg = 10;
case "RevolverImage":
%dmg = 25;
case "ThompsonImage":
%dmg = 7.5;
default:
%dmg = 1;
}
%brick.health-=%dmg;
if(%brick.health<=0)
{
%brick.fakekillbrick(getrandom("0,4") SPC getrandom("0,4") SPC getrandom("0,4"), 2);
%brick.schedule(1000,"delete");
}
}
}
Parent::onProjectileHit(%brick, %proj, %client);
}
};
activatepackage(BrickHealthPackage);
http://www.mediafire.com/file/rq734nvv818nnnb/Script_BrickHealth.zip