Changing dropitem without making a new monster

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Changing dropitem without making a new monster

Post by Jarewill »

Let's say I have a shotgun replacement that isn't a shotgun at all, like an ability or something.
However I don't want zombie shotgunners to drop that ability, but instead drop their shotguns.
I also don't want to create a new monster to replace them, as that would break compatibility with monster changing mods.
How exactly could I do it and is it even possible in Decorate or ACS?
Thanks in advance.
User avatar
m8f
 
 
Posts: 1464
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Location: Siberia (UTC+7)
Contact:

Re: Changing dropitem without making a new monster

Post by m8f »

A very simple solution comes to mind, but it's not Decorate or ACS.
User avatar
Dan_The_Noob
Posts: 880
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Changing dropitem without making a new monster

Post by Dan_The_Noob »

can you be more specific about what you are trying to achieve overall?
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: Changing dropitem without making a new monster

Post by wildweasel »

I must credit Ed the Bat for this trick, but I did something like this with ww-mixed3; Chaingunners drop a weapon that differs from the weapon that appears on Chaingun spawns, but the Chaingunners themselves are not replaced at all.

Firstly, neither your new ability nor the shotgun will have the "replaces" tag on them. Replace the weapon instead with an actor like this one:

Code: Select all

ACTOR SMGSpawner : CustomInventory replaces Chaingun
{
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_CheckFlag("TOSSED", "DropSMG")
		TNT1 A 0 A_DropItem("PPSH41")
		Stop
	DropSMG:
		TNT1 A 0 A_DropItem("OuchSMG")
		Stop
	}
}
The important part is that this actor, on spawn, checks itself for the +TOSSED flag, which means it is checking whether it has been placed in the map, or if it's been dropped by an enemy. In this case, if TOSSED is true, jump to the other state and drop the shotgun. If it is false, it falls through and drops the ability instead.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Changing dropitem without making a new monster

Post by Jarewill »

Thank you WildWeasel!
I was planning on using a custominventory anyways as I wanted the ability to be only picked up once and then the regular shotgun would be spawned. :P
And I was also hoping for a way to check if the actor was somehow dropped by an enemy, as I knew that those have different properties than regularly spawned actors.
But I had no idea if that was even possible, so thank you for the great help!
Ac!d
Posts: 348
Joined: Tue Apr 02, 2019 5:13 am

Re: Changing dropitem without making a new monster

Post by Ac!d »

It is possible to make this system in Zscript ?

I've tried to do this but i got a script warning :
Accessing deprecated function A_CheckFlag - deprecated since 2.3.0
User avatar
SanyaWaffles
Posts: 868
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields
Contact:

Re: Changing dropitem without making a new monster

Post by SanyaWaffles »

you'd use

Code: Select all

bTOSSED == true
within an anonymous function instead.
Ac!d
Posts: 348
Joined: Tue Apr 02, 2019 5:13 am

Re: Changing dropitem without making a new monster

Post by Ac!d »

SanyaWaffles wrote:you'd use

Code: Select all

bTOSSED == true
within an anonymous function instead.
I'm sorry but I need an exemple, I'm feeling stuck.
User avatar
SanyaWaffles
Posts: 868
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields
Contact:

Re: Changing dropitem without making a new monster

Post by SanyaWaffles »

Using the example posted, this is how you'd do it in ZScript.

Code: Select all

class SMGSpawner : CustomInventory replaces Chaingun
{
   States
   {
   Spawn:
      TNT1 A 0 NoDelay
      {
            // all pre-existing flags are prefixed with b
            // and are boolean values
            // you use return ResolveState(state) for jumps
            if (invoker.bTOSSED)
                 return ResolveState("DropSMG");
           
            // to not perform a jump, simply pass null
            return ResolveState(null);
      }
      TNT1 A 0 A_DropItem("PPSH41");
      Stop;
   DropSMG:
      TNT1 A 0 A_DropItem("OuchSMG");
      Stop;
   }
}
Last edited by SanyaWaffles on Mon Dec 16, 2019 9:57 pm, edited 1 time in total.
Ac!d
Posts: 348
Joined: Tue Apr 02, 2019 5:13 am

Re: Changing dropitem without making a new monster

Post by Ac!d »

I tried with your exemple, but I got a script error :
Self pointer used in ambiguous context; VM execution may abort!
User avatar
SanyaWaffles
Posts: 868
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields
Contact:

Re: Changing dropitem without making a new monster

Post by SanyaWaffles »

try using invoker.bTossed instead. I updated the code. It was late at night when I wrote it, apologies.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Changing dropitem without making a new monster

Post by Jarewill »

I deeply apologize for the long bump, but there's been something that's been plaguing my mind, but I didn't know if I should post about it or not.

Some time ago I've sent a test build to my friend who, because of hardware limitations, had to use an older version of GZDoom.
And they told me about a worrying message spam in the console. The message being:
UNKNOWN FLAG 'TOSSED' in 'ACTOR'

I've tested it with the newest LZDoom version (3.84) and the issue is also there.
I wanted to ask if there is a way to fix it without creating an LZDoom-specific version with those checks removed.

I'll provide a working example in case it should work, but I just did something wrong. Use with LZDoom or pre-4.x GZDoom.

EDIT: As it turns out, checking for "TOSSED" flag wasn't needed to begin with.
CustomInventories have a state designed for just what I've been looking for.
The Drop state. It's entered if a CustomInventory actor is dropped by a monster.
Attachments
test.wad
(397 Bytes) Downloaded 29 times
Post Reply

Return to “Scripting”