|
This article or section is outdated and has not been fully updated to reflect the current version of SRB2.
Please help the Wiki by correcting or removing any misinformation, as well as adding any new information to the page.
|
|
To do Update for 2.2.0:
- Var1 is used to determine damage type, leave at 0 for generic damage for instance
- If Var1 includes the flag
DMG_CANHURTSELF (which can be combined with the base damage type), the actor can actually hurt themselves!
- I think bosses can be damaged by this action now?
|
A_Explode is an action that is used to damage any Objects in the blockmap around the actor within a range determined by Damage
, which must be the distance required multiplied by FRACUNIT
. The target is used as the cause of the explosion, which will mean if a player is set as the target they will receive points from the actor damaging enemies or other players through this action.
Note that this action will not affect any non-shootable Objects, bosses, monitors, nor Objects not within the blockmap at all (MF_NOBLOCKMAP
). The actor and any Objects sharing the same type as the actor will also be unaffected. Furthermore, this action will not work through walls, and will not affect any Objects not visible from the actor's position.
Code – A_Explode
|
|
// Function: A_Explode
//
// Description: Explodes an object, doing damage to any objects nearby. The target is used as the cause of the explosion. Damage value is used as explosion range.
//
// var1 = damagetype
// var2 = unused
//
void A_Explode(mobj_t *actor)
{
INT32 locvar1 = var1;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_Explode", actor))
return;
#endif
P_RadiusAttack(actor, actor->target, actor->info->damage, locvar1);
}
|
|
Code - PIT_RadiusAttack/P_RadiusAttack
|
|
//
// RADIUS ATTACK
//
static fixed_t bombdamage;
static mobj_t *bombsource;
static mobj_t *bombspot;
static UINT8 bombdamagetype;
//
// PIT_RadiusAttack
// "bombsource" is the creature
// that caused the explosion at "bombspot".
//
static boolean PIT_RadiusAttack(mobj_t *thing)
{
fixed_t dx, dy, dz, dist;
if (thing == bombspot) // ignore the bomb itself (Deton fix)
return true;
if ((thing->flags & (MF_MONITOR|MF_SHOOTABLE)) != MF_SHOOTABLE)
return true;
if (bombsource && thing->type == bombsource->type && !(bombdamagetype & DMG_CANHURTSELF)) // ignore the type of guys who dropped the bomb (Jetty-Syn Bomber or Skim can bomb eachother, but not themselves.)
return true;
dx = abs(thing->x - bombspot->x);
dy = abs(thing->y - bombspot->y);
dz = abs(thing->z + (thing->height>>1) - bombspot->z);
dist = P_AproxDistance(P_AproxDistance(dx, dy), dz);
dist -= thing->radius;
if (dist < 0)
dist = 0;
if (dist >= bombdamage)
return true; // out of range
if (thing->floorz > bombspot->z && bombspot->ceilingz < thing->z)
return true;
if (thing->ceilingz < bombspot->z && bombspot->floorz > thing->z)
return true;
if (P_CheckSight(thing, bombspot))
{ // must be in direct path
P_DamageMobj(thing, bombspot, bombsource, 1, bombdamagetype); // Tails 01-11-2001
}
return true;
}
//
// P_RadiusAttack
// Source is the creature that caused the explosion at spot.
//
void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist, UINT8 damagetype)
{
INT32 x, y;
INT32 xl, xh, yl, yh;
fixed_t dist;
dist = FixedMul(damagedist, spot->scale) + MAXRADIUS;
yh = (unsigned)(spot->y + dist - bmaporgy)>>MAPBLOCKSHIFT;
yl = (unsigned)(spot->y - dist - bmaporgy)>>MAPBLOCKSHIFT;
xh = (unsigned)(spot->x + dist - bmaporgx)>>MAPBLOCKSHIFT;
xl = (unsigned)(spot->x - dist - bmaporgx)>>MAPBLOCKSHIFT;
BMBOUNDFIX(xl, xh, yl, yh);
bombspot = spot;
bombsource = source;
bombdamage = FixedMul(damagedist, spot->scale);
bombdamagetype = damagetype;
for (y = yl; y <= yh; y++)
for (x = xl; x <= xh; x++)
P_BlockThingsIterator(x, y, PIT_RadiusAttack);
}
|
|