Page 1 of 1

[ZScript] "Monsters Droppers"

Posted: Sat Aug 01, 2020 3:23 am
by Ac!d
I would like to make my mod compatible with customs monsters pack, but I would like to make a script which work like this :
- If the monster killed is a Zombieman or a inherited actor, he will drop a clip but if he's not, he will drop something else.

Code: Select all

Class ClipDrop : CustomInventory replaces Clip
{
	Default {}
	States
	{
	Spawn:
		TNT1 A 0 NoDelay
		{
			If(invoker.bTOSSED) // Credits
				Return ResolveState("Drop.Weapon"); // to
				Return ResolveState(Null); // SanyaWaffles
		}
		TNT1 A 0 A_SpawnItem("Clip");
		Stop;
	Drop.Weapon:
		TNT1 A 0
		{
			If( ... ) // What should I wrote ?
			{ A_DropItem("Clip"); } // For Zombieman only
			Else
			{ A_DropItem("Shell",4,256); } // Drop 4 Shells if the monster is not a Zombieman.
		}
		Stop;
	}
}

Re: [ZScript] "Monsters Droppers"

Posted: Sat Aug 01, 2020 9:28 am
by Jarewill
From what I understand, you are trying to make an item drop only when dropped by a certain enemy, right?
If so, then the SpecialDropAction virtual function is what you need for that.
For example:

Code: Select all

Class DropChooser : Inventory
{
    Override bool SpecialDropAction(Actor dropper)
    {
        If(dropper is "Zombieman"){A_DropItem("ClipBox");} //If actor that dropped the item is a zombieman (or derived), drop a clip box
        Else If(dropper is "ShotgunGuy"){A_DropItem("ShellBox");} //If actor is a shotgunguy (or derived), drop a shell box
        Return 1; //Destroy the item if it was dropped at all
    }
}
You can put this override instead of the "Drop.Weapon" state and the bTOSSED check, as it will remove the item if it was dropped.

Re: [ZScript] "Monsters Droppers"

Posted: Sat Aug 01, 2020 11:58 pm
by Ac!d
Thank you Jarewill, I've improved your code to make it compatible with monsters pack such as KriegslandEnemies.

Code: Select all

Class ClipDropChooser : Inventory replaces Clip
{
    Override bool SpecialDropAction(Actor dropper)
    {
        If(dropper is "Zombieman"){ A_DropItem("Clip"); } //If actor that dropped the item is a zombieman (or derived)
        Else { A_DropItem("ClipBox",25,256); }
        Return 1; //Destroy the item if it was dropped at all
    }
    States
    {
    Spawn:
        TNT1 A 0 NoDelay
        {
            If(invoker.bTOSSED)
                { A_SpawnItem("ClipDropChooser"); }
            Else
                { A_SpawnItem("Clip"); }
        }
        Stop;
   }
}