Page 1 of 1

ZScript - Intercept/Override ACS give inventory?

Posted: Wed Nov 17, 2021 1:34 pm
by kevansevans
I need the ability to intercept an ACS function that gives the player an item. My mod uses custom weapons that replace the default. If the map calls, as an example, giveInventory("Pistol", 1);, the player will receive the vanilla pistol and not my custom pistol that replaces it in ZScript.

Re: ZScript - Intercept/Override ACS give inventory?

Posted: Mon Nov 22, 2021 4:24 am
by Apeirogon
Its impossible?? ACS works on other "plane of existence", relatively to Zscript.
Also, even CheckReplacement event are not triggered in this case?

As a workaround, you can iterate over player inventory and check is he possess any item that should be replaced.

Re: ZScript - Intercept/Override ACS give inventory?

Posted: Tue Nov 23, 2021 6:10 am
by Player701
Apeirogon wrote:ACS works on other "plane of existence", relatively to Zscript.
Note that, in fact, the PCD_GIVEINVENTORY ACS opcode calls ScriptUtil::GiveInventory, which in turn calls Actor::GiveInventory; both of these are defined in ZScript. The actual problem is that Giveinventory calls Actor::Spawn without specifying ALLOW_REPLACE, so CheckReplacement et al. does not run. There is no way to override this except with hacks (like the one Apeirogon suggested).