A_ShootBullet is an action that makes the actor fire an Object at the target, playing the actor's AttackSound
. When the actor fires the chosen Object, the SeeSound
of the fired Object is also played. The actor's RaiseState
determines the Object type to shoot. PainChance
sets the shooting distance limit – if the target is further away from the actor than this limit, the actor does not shoot.
Object property
|
Use
|
RaiseState
|
Object type to shoot
|
SeeSound |
(Of Object being shot) Played when fired
|
AttackSound
|
Shooting sound
|
PainChance
|
Shooting distance limit
|
Code – A_ShootBullet
|
|
// Function: A_ShootBullet
//
// Description: Shoots a bullet. Raisestate defines object # to use as projectile.
//
// var1 = unused
// var2 = unused
//
void A_ShootBullet(mobj_t *actor)
{
fixed_t dist;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_ShootBullet", actor))
return;
#endif
if (!actor->target)
return;
dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z);
if (dist > FixedMul(actor->info->painchance*FRACUNIT, actor->scale))
return;
A_FaceTarget(actor);
P_SpawnMissile(actor, actor->target, (mobjtype_t)actor->info->raisestate);
if (actor->info->attacksound)
S_StartSound(actor, actor->info->attacksound);
}
|
|