[Added] CheckReplacee Event

Moderator: GZDoom Developers

CheckReplacee Event

Postby Major Cooke » Sun Jan 27, 2019 1:29 pm

Pull Request

There's one small pitfall when using CheckReplacement to replace actors; there's no way to get the actual replacee with it.

So what I suggest is CheckReplacee using a ReplacedEvent struct:

Code: Select allExpand view
struct ReplacedEvent native version("2.4")
{
   native Class<Actor> Replacee;
   native readonly Class<Actor> Replacement;
   native bool IsFinal;
}


Then it would be down to the modder to indicate under what class it belongs. This will especially be useful for mods that are made to combine and/or be friendly with other mods/addons.

Code: Select allExpand view
override void CheckReplacee(ReplacedEvent e)
{
   Class<Actor> rep = e.Replacement;
   
   static const Class<Actor> mons[] =
   {
      'MiniMind',
      'Demolisher',
      'Sentient'
   };
   
   for (int i = 0; i < mons.Size(); i++)
   {
      if (rep == mons[i])
      {
         e.Replacee = 'SpiderMastermind';
         e.IsFinal = true;
         return;
      }
   }
}


Sure, this might be a bit of book keeping, but right now:
  • A_BossDeath is partly broken (but can be fixed by using a randomspawner instead)
  • CheckReplacee, if used by mods that have little to no 'replaces' being used, is equally just as useless.

Having the CheckReplacee event function would solve both with a little book keeping by modders. In fact, it would be easy for modders to create an object with two arrays inside that keeps track of every new entity spawned, filled in whenever CheckReplacement is called.
Attachments
test.pk3
Load a map with zombiemen in it and the console will print some stuff about Z2 replacing them.
(542 Bytes) Downloaded 2 times
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: CheckReplacee Event

Postby Major Cooke » Sun Jan 27, 2019 7:09 pm

Added PR and a test file. Zombiemen are replaced via CheckReplacements and without the use of 'replaces' keyword, which is attributed by CheckReplacee.
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: CheckReplacee Event

Postby Major Cooke » Thu Jan 31, 2019 1:44 pm

Thanks for merging. This can be closed.
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: Bing [Bot] and 1 guest