CheckReplacee Event

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: CheckReplacee Event

Re: CheckReplacee Event

by Major Cooke » Thu Jan 31, 2019 12:44 pm

Thanks for merging. This can be closed.

Re: CheckReplacee Event

by Major Cooke » Sun Jan 27, 2019 6: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.

CheckReplacee Event

by Major Cooke » Sun Jan 27, 2019 12: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 all

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 all

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 47 times

Top