news about forums links tools tutorials contact

Bullet Holes - author: ^Soul^
Here is some quick code I did for a project i'm currently apart of. Use it as you like, however i'd be pleased to know what you use it for. Its fairly generalized and you can use it for bullet holes, scorch marks, blood splatters etc..etc.. It is a modified ProcessTraceHit(), so its called by TraceHit(), now it doesn't have to be used by trace hit, you could copy it into a projectile's HitWall() for a rocket/grenade/etc, but i'd suggest if your using a projectile to still call TraceHit() and leave the code here as is, for better reliability.
    function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal,
                    Vector X, Vector Y, Vector Z)
    {
      // This is a container for the Bullet Hole effect
      local actor BH;

      // This var will be used later to determine the floor
      local Float FloorNormal;

      // This dot product returns a float number -1.0 is the
      // ceiling, 1.0 is the floor, 0.0 is a wall..this of
      // course assumes the surfaces are flat
      FloorNormal = HitNormal Dot vect(0,0,1);

      // you don't want it to appear on people, or their dead bodies =)
      if ((!Other.Isa('Pawn')) && (!Other.IsA('Carcass')))
      {
        // And it looks like crap on the floor if the texture is like
        // grass or somthing so don't draw it
        if (FloorNormal < 1.00)
        {
          // Do the Deed =P
          // HitEffect is declared elsewhere as:
          // var() Class HitEffect;
          BH = Spawn(HitEffect,,,HitLocation);

          // Make it stick to the obj
          BH.SetBase(Other);

          // the gfx used was to big, so i  shrank it
          BH.DrawScale /= 10;
        }
      }
    }