I've been working on an updated version of the default library scripts - particularly the character & weapons. The next version will support decals as a part of the 'HitFX' effect that the weapons fire.
Next step is to do a per-material lookup of what you are shooting to place appropriate decals, but the basic framework is there.
For the scripting types, it's pretty simple. I've also added a small AreaForce to the location that the shot occurs so that you can have physics-based objects react to being shot etc.
This is a snippet from the weapon_handheld.gsl script (around line 515):
Object@ hitObject = GetGameManager().GetWorld().RayCast( muzzlePos, shotDirection, distance, intersect, normal, false);
if (wasVisible) object.Show();
if (hitObject != null)
{
// special fx for bullet hit
String str = hitObject.GetControllerSettingString( "HitFX");
if (str.IsEmpty())
str = defaultHitFX;
if (!str.IsEmpty())
{
// do hit effect and bullet hole
PushFullPath( hitObject.GetFullPath());
//DebugPrint("HitObject path: " + hitObject.GetFullPath(), true);
// spawn the effect
FXObject fxObject = GetFXManager().CreateFXAtPosition( str, intersect);
// update it's matrix based on what we hit
Matrix fx;
fx.ZAxis = -normal;
// check and see if we are shooting the ground or a wall
if (normal.y > 0.7)
fx.YAxis.Set(1,0,0);
else
fx.YAxis.Set(0,1,0);
fx.Orthogonalize(2, 1);
// adjust it's position so we don't have z-fighting
fx.T = intersect + (normal * 0.01);
// and update the effect
fxObject.SetMatrix( fx);
PopPath();
}
// tell the object it was hit
if (damage > 0)
{
hitObject.SetControllerVariable( "HitNormal", normal);
hitObject.SetControllerVariable( "HitPosition", intersect);
hitObject.SetControllerVariable( "HitDamage", damage);
}
// add a small force so physics objects look like they were shot
GetGameManager().GetWorld().AddAreaForce( intersect, 2, 1500);