Este tutorial a modo de ejemplo, muestra el código necesario para crear una arma capaz de quemar a los enemigos. Tendremos en cuenta que es para UT2004.
BurnerProj.ucc
//===============================================
// BurnerProj.
//===============================================
class BurnerProj expands Projectile;
var float HurtTime;
var float LifeTime; //how long it lives
Function Tick(float deltatime)
{
HurtTime+=deltatime;
LifeTime-=deltatime;
if (HurtTime>0.3)
{
//Hurt the target
Base.TakeDamage(Damage,Instigator,Location,Vect(0,0,0),'Burned'); HurtTime=0;
// Basically ever .3 deltatime this hurts some one
}
if ((LifeTime<0)||(Base==None))
{
Destroy(); //When its life is up, it dies
}
}
defaultproperties
{
Damage=5.000000 // How much damage it does
Mesh=LodMesh'UnrealShare.FlameM' // What it looks like
bUnlit=True
}
Si quisieramos que el proyectil fueran granadas de gas venenoso o flechas envenenadas, siempre podremos cambiar el damage type y borrar la mesh que no usemos.
Así que añadimos el siguiente código a el archivo que hemos creado:
simulated function ProcessTouch (Actor Other, Vector HitLocation)
{
local BurnerProj AnOther,FinalBurn;
if ( Other.Isa('Pawn')) // If the targets a pawn(bot, player, monster, etc.)
{
//This makes sure a person is only set on fire once
foreach AllActors(class'BurnerProj',AnOther)
{
If (AnOther.Base==Other)
FinalBurn=AnOther;
}
//If that person not already on fire
If (FinalBurn==None)
{
//Make the fire
FinalBurn=Spawn(class'BurnerProj',Instigator,,Other.Location,Other.Rotation)
//Set if to have a life time of 1(good for flame-thrower, but if you
//are making a incendiary arrow, or so forth, crank it up to something like 5
FinalBurn.LifeTime=1.0;
// Attaches the fire to the target
FinalBurn.SetBase(Other);
}
else
{
// If the target already on fire, make the fire last longer.
FinalBurn.LifeTime+=5.0;
}
}
}