[Added] CanResurrect virtual

Moderator: Developers

CanResurrect virtual

Postby Major Cooke » Sun Oct 14, 2018 8:52 am

Pull Request

CanResurrect(Actor other, bool passive)

Coded similarly to CanCollideWith, meaning it comes after all the other checks: a Raise state and either -1 tics or CanRaise keyword are still required.

Unlike CanCollideWith, other CAN be null, or it can be self (active only - the code doesn't even bother with pointlessly running twice).

This zombieman will print stuff based on who raised it. It will lay dead for five seconds before resurrecting itself so you can summon an archvile and have it resurrect to print something else.
Code: Select allExpand view
Class RZ : Zombieman
{
   override bool CanResurrect(Actor other, bool passive)
   {
      if (!passive)
      {
         if (other == null || other == self)
            Console.Printf("Actively reviving self");
         else
            Console.Printf("Reviving someone else");
      }
      else
      {
         if (other == null)
            Console.Printf("Being revived by The Powers That May Be!");
         else
            Console.Printf("Being revived by a monster");
      }
      return true;
   }
   
   Default
   {
      Health 1;
   }
   
   States
   {
   XDeath:
   Death:
      POSS H 5;
      POSS I 5 A_Scream;
      POSS J 5 A_NoBlocking;
      POSS K 5 CanRaise;
      POSS L 175 CanRaise;
      POSS L -1 A_RaiseSelf(RF_NOCHECKPOSITION);
      Stop;
   }
}


Spoiler: Old post
Last edited by Major Cooke on Mon Nov 05, 2018 9:33 pm, edited 1 time in total.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: CanResurrect virtual

Postby phantombeta » Sun Oct 14, 2018 8:54 am

Wouldn't it be better for it to have a "passive" bool argument like CanCollideWith, so it can be defined either in the monster being resurrected, or in the healer?
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

Re: CanResurrect virtual

Postby Major Cooke » Tue Nov 06, 2018 12:28 pm

Done.

Also I just pushed two more commits, adding A_RaiseActor and fixing an inconsistency. Whenever no raise state is found, P_Thing_Raise returned true while P_Thing_CanRaise returned false.

Now they both return false for that condition.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: CanResurrect virtual

Postby Blue Shadow » Tue Nov 06, 2018 1:45 pm

Major Cooke wrote:adding A_RaiseActor

Can't you just use A_RaiseSelf?
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010

Re: CanResurrect virtual

Postby Major Cooke » Tue Nov 06, 2018 4:40 pm

No. The 'other' actor in CanResurrect will always either be null or self if using A_RaiseSelf. This will not suffice.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: CanResurrect virtual

Postby Blue Shadow » Tue Nov 06, 2018 6:24 pm

Oh, I see, for that.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010

Re: CanResurrect virtual

Postby Major Cooke » Wed Nov 07, 2018 3:26 pm

Graf, I changed the name as you requested to just RaiseActor.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: CanResurrect virtual

Postby Lord Misfit » Tue Nov 13, 2018 12:14 pm

Hopefully this can work out. I've been trying to find a good way to make options for controlling what certain monsters can and can't resurrect without having to resort to possibly more hacky methods. I'd like to have the option to make Archviles/their ilk more challenging for those who want the option, yet not outright force it on those who don't like it either. :P
User avatar
Lord Misfit
Servant of Aetherius?
 
Joined: 27 Dec 2006
Location: Canton, OH
Discord: Lord Misfit#9594

Re: CanResurrect virtual

Postby Major Cooke » Tue Nov 13, 2018 1:04 pm

Well, it's in now! :mrgreen:
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: CanResurrect virtual

Postby Blue Shadow » Sat Nov 17, 2018 10:11 am

I don't know if this is an oversight or intended, but here goes:

In P_CheckForResurrection(), P_CanResurrect() is called like this:

Code: Select allExpand view
if (!check || !P_CanResurrect(self, corpsehit)) continue;

In P_Thing_Raise(), however, it's called like this:

Code: Select allExpand view
if (!P_CanResurrect(thing, raiser))

Notice the different order between the two calls in which the raiser and resurrectee are passed to the function. This creates an inconsistency when it comes to the meaning of passive vs. non-passive depending on which calling function is used (P_CheckForResurrection() or P_Thing_Raise()).
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010

Re: CanResurrect virtual

Postby Graf Zahl » Sat Nov 17, 2018 10:16 am

This stuff happens if people name their variables 'thing' and 'tmthing'. It defeats the concept of self-documenting code...
Doom is full of such misdeeds and many have carried over until now.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CanResurrect virtual

Postby Major Cooke » Sat Nov 17, 2018 10:43 am

I just realized something.

Code: Select allExpand view
P_Thing_Raise(self->master, copy ? self : NULL, (flags & RF_NOCHECKPOSITION));
ACTION_RETURN_BOOL(P_Thing_Raise(self, NULL, (flags & RF_NOCHECKPOSITION)));


So now those functions (A_RaiseMaster, A_RaiseSelf, etc.) might not work anymore, because if there's no raiser, P_CanResurrect returns false.

Code: Select allExpand view
if (raiser == nullptr)
   return false;


Because of stuff like this:
Code: Select allExpand view
auto clss = raiser->GetClass();


I'll make changes to the action functions to ensure raiser always points to the calling actor, and I'll change the flags so they're checked in P_Thing_Raise.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests