Difference between revisions of "Lost soul charging backwards"

From DoomWiki.org

[unchecked revision][checked revision]
(lost soul can still "attack" while helpless (wording is still somewhat out-of-universe due to lack of source code analysis); +cross-reference)
(I'd argue this is not a bug, but an intended behavior, no matter how odd it looks, because it's quite clearly deliberately special-case coded to behave this way)
Line 9: Line 9:
  
 
In the third case, if the object struck has [[hit point]]s, it receives the normal attack damage (no matter which direction the lost soul is facing).
 
In the third case, if the object struck has [[hit point]]s, it receives the normal attack damage (no matter which direction the lost soul is facing).
 +
 +
This behavior is caused by special coding in {{c|P_DamageMobj}}. When a lost soul starts charging, it has the {{c|MF_SKULLFLY}} flag set. A [[mobj]] that is damaged and that has this flag set has its momentum reduced to zero:
 +
 +
    if ( target->flags & MF_SKULLFLY )
 +
    {
 +
target->momx = target->momy = target->momz = 0;
 +
    }
 +
 +
Later in the function, the lost soul gets its momentum adjusted a bit as every damaged mobj is thrust away by the attack, depending on damage dealt and the mobj's mass (unless the damage was inflicted by a [[chainsaw]]. This part of the code is not specific to lost souls.
 +
 +
The second part of the special coding for charging lost souls in {{c|P_DamageMobj}} prevents the lost soul from getting put into its normal pain state, as if it had zero pain chance.
 +
    if ( (P_Random () < target->info->painchance)
 +
&& !(target->flags&MF_SKULLFLY) )
 +
    {
 +
target->flags |= MF_JUSTHIT; // fight back!
 +
 +
P_SetMobjState (target, target->info->painstate);
 +
    }
 +
 +
The combination of these two special coding makes it so that a lost soul that is damaged during a charge stays in a charge, and therefore has to wait until it collides with something to start performing any new action, while being robbed of its original momentum.
  
 
==See also==
 
==See also==

Revision as of 09:37, 27 April 2015

When hit by an attack, a lost soul that is charging will drift slowly away from the direction of the attack while remaining rather helplessly in its own attack state. This is, firstly, because the attack on the lost soul cancels out the forward motion of its charge. Secondly, since the lost soul 'floats', it will persistently drift away from the effect of the attack, rather than merely be pushed a short and limited distance.

Once commenced, the 'repulsed charging' will stop when:

  • The lost soul is hit by a different attacker, which becomes its new target.
  • The lost soul is stopped by an impassable or monster-blocking linedef.
  • The lost soul is stopped by a thing that is an 'obstacle' or by a collectible item.
  • The target of the lost soul, the one that caused the effect, is destroyed.

In the third case, if the object struck has hit points, it receives the normal attack damage (no matter which direction the lost soul is facing).

This behavior is caused by special coding in P_DamageMobj. When a lost soul starts charging, it has the MF_SKULLFLY flag set. A mobj that is damaged and that has this flag set has its momentum reduced to zero:

    if ( target->flags & MF_SKULLFLY )
    {
	target->momx = target->momy = target->momz = 0;
    }

Later in the function, the lost soul gets its momentum adjusted a bit as every damaged mobj is thrust away by the attack, depending on damage dealt and the mobj's mass (unless the damage was inflicted by a chainsaw. This part of the code is not specific to lost souls.

The second part of the special coding for charging lost souls in P_DamageMobj prevents the lost soul from getting put into its normal pain state, as if it had zero pain chance.

    if ( (P_Random () < target->info->painchance)
	 && !(target->flags&MF_SKULLFLY) )
    {
	target->flags |= MF_JUSTHIT;	// fight back!
	
	P_SetMobjState (target, target->info->painstate);
    }

The combination of these two special coding makes it so that a lost soul that is damaged during a charge stays in a charge, and therefore has to wait until it collides with something to start performing any new action, while being robbed of its original momentum.

See also