CanCrossLine virtual

Like feature suggestions, but you've actually written code to make it happen. More likely to make it into the game than some random request in feature suggestions.

Moderator: GZDoom Developers

Forum rules
Please see Code submission guidelines

GZDoom Status:
Image

Legacy Status:
Image Image

QZDoom Status:
Image

CanCrossLine virtual

Postby Major Cooke » Sun Aug 23, 2020 4:16 pm

Pull Request

Pretty simple virtual. Since there's no way to really tell if an actor can cross certain lines, I had to come up with this for the sake of not needing to recreate A_Chase by hand.
Returning false means the line is blocking. Side is the side of the line the actor is on, currently, at the time of calling.

This function occurs after most PIT_CheckLine checks, but before other sector updating code near the end, meaning it handles things like MaxStepHeight before it calls this function.

Example code here allows for monsters to cross over and out of damaging floors, since I have programmed them to take damage from damaging floors just like players do via the Tick() override.
Code: Select allExpand view
override bool CanCrossLine(Line crossing, int side)
{
   // Already in a sector that's burning the monster, and may need to
   // cross over some in order to reach ground without it, so allow it.
   if (CurSector.DamageAmount > 0)
      return true;
   
   Line l = crossing;
   
   // If walking away from the direction of the damage sector, allow
   // walking over the line. Otherwise they can get stuck.
   double ang = VectorAngle(l.delta.x, l.delta.y) + 90;
   double delta = AbsAngle(ang, angle);
   
   if (l.frontsector.DamageAmount < 1 && delta >= 90)
      return true;
   if (l.backsector.DamageAmount < 1 && delta <= 90)
      return true;
   
   // Crossing over the front side, so check the back sector.
   if (side == Line.Front)
      return (l.backsector.DamageAmount < 1);
   
   // Vice versa.
   return (l.frontsector.DamageAmount < 1);
}
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: CanCrossLine virtual

Postby Major Cooke » Sun Sep 27, 2020 3:23 pm

I redid the submission. Hopefully its better now.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007


Return to Code Submissions

Who is online

Users browsing this forum: No registered users and 0 guests