Author Topic: Detecting what kind of explosion hit a brick [Need Help]  (Read 3043 times)

Is there a way to detect what kind of damage was done to a brick when the brick is damaged? I want to have a check to see that if a brick is damaged by a certain explosion, this will happen, else nothing. So for instance; there is a door and someone plants C4 on it. I want certain functions to activate only when the C4 explosion damages the brick, not when a vehicle explosion damages the brick. Im guessing it has something to do with the ::Damage function?
« Last Edit: June 27, 2014, 08:34:24 PM by Gordo12699 »

The first argument of :: damage (for direct hit weapons, eg. guns) and ::radiusdamage (for explosions) should be the projectile datablock

Maybe package the ProjectileData::onCollision.

for the ProjectileData::Damage function, it is not announcing that the bank has been robbed. Here is the code:
Code: [Select]
function TimeBombFinalExplosionProjectile::damage(%projectile,%obj,%col,%fade,%pos,%normal)
{
%damageType = $DamageType::Direct;
if(%this.DirectDamageType)
%damageType = %this.DirectDamageType;

%scale = getWord(%obj.getScale(), 2);
%directDamage = mClampF(%this.directDamage, -100, 100) * %scale;

if(%col.getType() & $TypeMasks::PlayerObjectType)
{
  %col.damage(%obj, %pos, %directDamage, %damageType);
}
else if(%col.getDatablock().uiName $= "Bank Brick")
{
messageAll('', "\c3The bank has been robbed!");
}
else
{
%col.damage(%obj, %pos, %directDamage, %damageType);
}
}

Maybe I have the parameters wrong or something?

for the ProjectileData::Damage function, it is not announcing that the bank has been robbed. Here is the code:
Code: [Select]
function TimeBombFinalExplosionProjectile::damage(%projectile,%obj,%col,%fade,%pos,%normal)
{
%damageType = $DamageType::Direct;
if(%this.DirectDamageType)
%damageType = %this.DirectDamageType;

%scale = getWord(%obj.getScale(), 2);
%directDamage = mClampF(%this.directDamage, -100, 100) * %scale;

if(%col.getType() & $TypeMasks::PlayerObjectType)
{
  %col.damage(%obj, %pos, %directDamage, %damageType);
}
else if(%col.getDatablock().uiName $= "Bank Brick")
{
messageAll('', "\c3The bank has been robbed!");
}
else
{
%col.damage(%obj, %pos, %directDamage, %damageType);
}
}

Maybe I have the parameters wrong or something?
%this doesn't exist. You set it as %projectile.

After setting %projectile back to %this, there is still no "The bank has been robbed!" message.

Maybe the brick's ui name isn't Bank Brick?

That if/else-if/else thing could be compacted to just if/else.

if this is the brick we're looking for
    do stuff
else
    damage

Does Projectile::damage even get called on bricks?

Personally, I would package Projectile::onExplode, then do a radius search for bricks, then check if its the brick you're looking for.

Personally, I would package Projectile::onExplode, then do a radius search for bricks, then check if its the brick you're looking for.

Why? Just use ProjectileData::radiusDamage(%this, %obj, %col, %distanceFactor, %pos, %damageAmt).

Why? Just use ProjectileData::radiusDamage(%this, %obj, %col, %distanceFactor, %pos, %damageAmt).

Because I'm not sure if that gets called on bricks.
« Last Edit: June 28, 2014, 09:04:58 AM by boodals 2 »

Because I'm not sure if that gets called on bricks.

Er, let me check, hold on. ::damage and ::radiusDamage aren't used for bricks, weird. The game uses a radius search in ::onExplode for nothing but bricks by default.
« Last Edit: June 28, 2014, 09:31:39 AM by portify »