[ZS] Monster drops ammo instead of weapon until certain map?

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!)

[ZS] Monster drops ammo instead of weapon until certain map?

Postby Ebenezer Fottingnotch » Wed Jun 15, 2022 1:42 pm

How would I make the Shotgun and Chaingun guys drop their respective weapons only after a certain map is reached in my wad? For example I have a lot of Shotgun Guys in maps 01 and 02 but I have secret areas with Shotguns in them, how would I prevent players from just getting the SG off the killed enemies in these maps, but from map03 onward, they drop SGs like normal? I want to keep the replacement monster the same actor and not have to make an inherited clone that only drops ammo.
Ebenezer Fottingnotch
 

Re: [ZS] Monster drops ammo instead of weapon until certain

Postby Blue Shadow » Wed Jun 15, 2022 11:52 pm

Something like this, I suppose:

Code: Select allExpand view
class ShotgunGuy2 : ShotgunGuy replaces ShotgunGuy
{
    void SGGuy_NoBlocking ()
    {
        // On maps 1 and 2, drop shells, otherwise drop the default item.
        if (Level.levelnum < 3)
        {
            A_NoBlocking(false);
            A_DropItem("Shell");
        }
        else
        
{
            A_NoBlocking();
        }
    }

    States
    
{
    Death:
        SPOS H 5;
        SPOS I 5 A_Scream;
        SPOS J 5 SGGuy_NoBlocking;
        SPOS K 5;
        SPOS L -1;
        Stop;
    XDeath:
        SPOS M 5;
        SPOS N 5 A_XScream;
        SPOS O 5 SGGuy_NoBlocking;
        SPOS PQRST 5;
        SPOS U -1;
        Stop;
    }
}

If you're confused by A_NoBlocking, read its documentation.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: [ZS] Monster drops ammo instead of weapon until certain

Postby Cherno » Thu Jun 16, 2022 2:28 am

Ebenezer Fottingnotch wrote:I want to keep the replacement monster the same actor and not have to make an inherited clone that only drops ammo.


However, I don't see another solution.
User avatar
Cherno
 
Joined: 06 Dec 2016

Re: [ZS] Monster drops ammo instead of weapon until certain

Postby Apeirogon » Thu Jun 16, 2022 10:08 am

Its possible with event handlers WorldThingSpawned/CheckReplacement virtuals, but it will make map compatible with gzdoom only.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: [ZS] Monster drops ammo instead of weapon until certain

Postby Ebenezer Fottingnotch » Thu Jun 16, 2022 12:03 pm

[quote="Blue Shadow"]Something like this, I suppose:

[snip]

[/quote]

That's workable enough, thanks. Wasn't quite sure how to declare the levelnum thing in ZScript until now.
Ebenezer Fottingnotch
 


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest