You can combine ZScript with DECORATE, but you cannot use DECORATE-based actors in your ZScript code because DECORATE is parsed after ZScript. However, this does not prevent you from using CheckReplacement to manage replacements of existing actors with your custom DECORATE-based actors. This is possible because CheckReplacement deals with class names rather than actual actor instances, so your ZScript will compile without errors.
For the most comprehensive ZScript language and API documentation available at the moment, see
here. Also check out
the wiki for many useful articles on various ZScript topics. In particular, a lot of information on event handlers can be found
here.
Now, regarding your particular use case. This is what Caligari87's code would look like in ZScript with CheckReplacement:
Code: Select all
version "4.5"
class MyEventHandler : EventHandler
{
override void CheckReplacement(ReplaceEvent e)
{
if (e.Replacee == 'Shotgun' || e.Replacee == 'Chaingun')
{
e.Replacement = 'MyCustomWeapon';
}
}
}
You should not forget to add your event handler in your
MAPINFO lump, otherwise GZDoom will not register it in the game:
Code: Select all
gameinfo
{
AddEventHandlers = "MyEventHandler"
}