I have no idea how to do this, so I'm going to ask here.
I'm making a pk3 file that has several different player classes. I want these classes to all use the same generic set of weapons (fists, pistol, shotgun, etc), but I want to change the weapon sprites in minor ways (example: having a purple outline on one, having a different hammer on another) for each class. I know how to inherent from the base classes and change the sprites, so that's not the issue.
What I'm wondering is: when the player picks up a weapon they don't already have, how would I make it give them their variant of the weapon instead of the base one?
Different Weapon Sprites for Different Actors
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!)
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!)
-
- Posts: 30
- Joined: Sat Jun 19, 2021 6:35 am
- Preferred Pronouns: She/Her
Re: Different Weapon Sprites for Different Actors
You can use a CustomInventory item for that.
CustomInventory allows for custom pickup sequences, so you can give the players a weapon based on their class:
However making them change pickup sprites based on the class is not multiplayer-friendly without the use of ZScript.
CustomInventory allows for custom pickup sequences, so you can give the players a weapon based on their class:
Code: Select all
ACTOR NewShotgun : CustomInventory replaces Shotgun
{
Inventory.PickupMessage "Picked up a shotgun"
Inventory.PickupSound "misc/w_pkup"
States
{
Spawn:
SHOT A -1
Stop
Pickup: //Make sure to define a token item and give it as a class's starting item, it will be needed for those checks
TNT1 A 0 A_JumpIfInventory("Class1Token",1,"Class1") //First class will jump to the first state
TNT1 A 0 A_JumpIfInventory("Class2Token",1,"Class2") //Second class will jump to the second one
TNT1 A 0 A_JumpIfInventory("Class3Token",1,"Class3") //And third to the third
Fail //If all else fails, fail this too
Class1:
TNT1 A 0 A_GiveInventory("Shotgun1",1) //Give weapon 1 to class 1
Stop
Class2:
TNT1 A 0 A_GiveInventory("Shotgun2",1) //Weapon 2 to class 2
Stop
Class3:
TNT1 A 0 A_GiveInventory("Shotgun3",1) //Weapon 3 to class 3
Stop
}
}
-
- Posts: 30
- Joined: Sat Jun 19, 2021 6:35 am
- Preferred Pronouns: She/Her
Re: Different Weapon Sprites for Different Actors
Okay so, I tried it (although I excluded the other two classes from the code to test it).
I spawned the shotgun into a test map, and it appears there but I can't pick it up.
If it helps any, this is the the code for the "purple shotgun"
And the code for the token. This actually might be what messed it up, because I didn't add any properties to it, but I honestly don't know.
EDIT:
I figured it out!
The token WAS the problem. I had to make JossToken inherent from Inventory. I feel like I should've figured that out far before I did, but eventually I did.
Thanks for your help!
Code: Select all
ACTOR ShotgunReplacer : CustomInventory replaces Shotgun
{
Inventory.PickupMessage "Picked up a shotgun."
Inventory.PickupSound "misc/w_pkup"
States
{
Spawn:
SHOT A -1
Stop
Pickup: //Make sure to define a token item and give it as a class's starting item, it will be needed for those checks
TNT1 A 0 A_JumpIfInventory("JossToken",1, "Class1") //First class will jump to the first state
Fail //If all else fails, fail this too
Class1:
TNT1 A 0 A_GiveInventory("purpleShotgun",1) //Give weapon 1 to class 1
Stop
}
}
If it helps any, this is the the code for the "purple shotgun"
Code: Select all
ACTOR purpleShotgun : Shotgun
{
Weapon.SlotNumber 3
Inventory.Pickupmessage "$GOTSHOTGUN"
States
{
Ready:
SHTP A 1 A_WeaponReady
Loop
Deselect:
SHTP A 1 A_Lower
Loop
Select:
SHTP A 1 A_Raise
Loop
Fire:
SHTP A 3
SHTP A 7 A_FireShotgun
SHTP BC 5
SHTP D 4
SHTP CB 5
SHTP A 3
SHTP A 7 A_ReFire
Goto Ready
Flash:
SHTP A 4 Bright A_Light1
SHTP B 3 Bright A_Light2
Goto LightDone
Spawn:
SHOT A -1
Stop
}
}
Code: Select all
ACTOR JossToken
{
}
I figured it out!
The token WAS the problem. I had to make JossToken inherent from Inventory. I feel like I should've figured that out far before I did, but eventually I did.
Thanks for your help!