I need help with classes

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
KeaganH
Posts: 32
Joined: Fri Sep 25, 2020 4:54 pm

I need help with classes

Post by KeaganH »

I'm making a mod that has two different player classes and they use different weapons, and I'm trying to make an actor that spawns a gun only obtainable by a certain class, I tried using another mod (I won't list it because it's a very controversial mod) for help but there are always issues.

Here's the code I found from the mod:

Code: Select all

ACTOR SLOTONESPAWN2 : CustomInventory replaces Shotgun 18939
{
 //+INVENTORY.ALWAYSPICKUP
 +COUNTITEM
 States
 {
 Spawn:
  CRBT A -1
  Stop
 Pickup:
  TNT1 A 0 A_JumpIfInventory("Glock18",1,6)
  TNT1 A 0 A_JumpIfInventory("BenFist",1,3)
  TNT1 A 0 A_GiveInventory("Gewehr41")
  TNT1 A 2 A_Jump(256, 5)
  TNT1 A 0 A_GiveInventory("ShotgunA")
  TNT1 A 2 A_Jump(256, 3)
  TNT1 A 0 A_GiveInventory("MoonTalkRifle")
  TNT1 A 0 A_GiveInventory("Rifle")
  TNT1 A 0
  TNT1 A 1
  stop
  }
}
I hope that I can fix this issue as fast as possible.

Sincerely, Keagan H.
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: I need help with classes

Post by Player701 »

KeaganH wrote:I'm trying to make an actor that spawns a gun only obtainable by a certain class
I'm not sure why you need "an actor that spawns a gun". Why not just put Inventory.RestrictedTo on the gun itself? Players not using one of the matching class(es) will not be able to pick it up as a result. They will still be able to pick it up for ammo, but you can use INVENTORY.RESTRICTABSOLUTELY to disable this behavior. A_GiveInventory will also silently fail if it detects a class mismatch, and nothing bad will happen.

If you still need another actor to spawn your gun, then I assume there must be some condition that will make it spawn the gun or something else (maybe nothing at all) depending on the outcome? In this case, what kind of condition do you want it to be? Do note that if you want to check the player's class, it is possible that there might be more than one player in the game (and players can also change their classes during a multiplayer game). Additionally, weapons and other items spawned this way will not be subject to the "weapons stay" and/or "items respawn" gameplay options unless spawned by means of an actor derived from a RandomSpawner (or you must use ZScript to clear the DROPPED flag on the newly-spawned item).
Post Reply

Return to “Scripting”