giving weapons to specific player classes (BrutalDoomLite)

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
User avatar
nekostuffing
Posts: 60
Joined: Sat Aug 31, 2019 8:08 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support

giving weapons to specific player classes (BrutalDoomLite)

Post by nekostuffing »

so im using BDlite as a base to make and i made two player classes each with its own weapons ...however im having tuble with replacing the original weapons with new ones for example the Heavybolter replaces the chaingun for the BloodAngel player class but the BTheavybolter also replaces the chaingun for the BlackTemplar player class and when i play as a BloodAngel and pick up the a havybolter i end up getting the BTheavybolter that should only be given to the BlackTemplar player class.

This is the BloodAngel Heavybolter

Code: Select all

ACTOR Heavybolter : BDLiteWeapon Replaces Chaingun
{
Game Doom
SpawnID 28
Weapon.SelectionOrder 700
Weapon.AmmoType1 "RifleAmmo"
Weapon.AmmoGive 30
Weapon.AmmoUse1 1
Weapon.SlotNumber 4
Weapon.BobRangeX 0.0
Inventory.ForbiddenTo BlackTemplar
VisibleToPlayerClass BloodAngel 
Inventory.PickupSound "weapons/chaingun/pickup"
Inventory.PickupMessage "You got the Minigun!"
Obituary "%o was mown down by %k's Minigun."
AttackSound "none"
States
{
    Spawn:
        MGUN A -1
        Stop
    Ready:
        CHGS ABCD 1
        TNT1 A 0 A_PlaySound("weapons/chaingun/draw")
    ReadyLoop:
        CHAG A 1 A_WeaponReady(WRF_ALLOWZOOM)
        Goto ReadyLoop
    Deselect:
        CHGS DCBA 1
        TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
        TNT1 A 1
        Wait
    NoAmmo:
        CHAE A 10 A_PlaySound("weapons/empty")
        Goto ReadyLoop
            
    Fire:
        TNT1 A 0 A_AlertMonsters
        CHAG BCD 0
        CHAG BCDBCD 0
        TNT1 A 0
    Hold:
        TNT1 A 0 A_Recoil(0.1)
        TNT1 A 0 A_SetAngle(random(1, -1) + angle)
        TNT1 A 0 A_SetPitch(-0.4 + pitch)
        
        //Main firing loop
        TNT1 A 0 A_PlaySound("weapons/chaingun/fire", 1)
        TNT1 A 0 A_Recoil(0.1)
        TNT1 A 0 A_FireCustomMissile("PlayerQuakeSmall", 0, 0, 0, 0)
        CHAF A 1 BRIGHT A_FireBullets(6, 4, 1, 9, "MachineGunBulletPuff", 1)
        TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
        TNT1 A 0 BRIGHT A_FireCustomMissile("MastermindTracer", random(-3,3), 0, 5, 5, 0, random(-3,3))
        TNT1 A 0 A_SpawnItemEx("BulletCasing", 17, 3, 35, 0, random(3,6), random(3,7))
        CHAF B 1
        TNT1 A 0 A_PlaySound("weapons/chaingun/fire", 1)
        CHAF J 1 BRIGHT A_FireBullets(6, 4, 1, 9, "MachineGunBulletPuff", 1)
        TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
        TNT1 A 0 A_SpawnItemEx("BulletCasing", 17, 3, 35, 0, random(3,6), random(3,7))
        CHAF H 1 A_SetAngle(random(1, -1) + angle)
        TNT1 A 0 A_ReFire
        
        //Cooldown
        CHAG A 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG B 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_Refire
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG C 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG D 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)    

        CHAG A 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG B 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG C 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG D 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)

        CHAG A 2
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG B 2
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG C 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG D 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG ABCD 2 A_WeaponReady
        CHAG ABCD 3 A_WeaponReady
        goto ReadyLoop
    }
}
This is the BlackTemplar Heavybolter

Code: Select all

ACTOR BTHeavybolter : BlackTemplarWeapon Replaces Chaingun
{
Game Doom
SpawnID 28
Weapon.SelectionOrder 700
Weapon.AmmoType1 "RifleAmmo"
Weapon.AmmoGive 30
Weapon.AmmoUse1 1
Weapon.SlotNumber 4
Weapon.BobRangeX 0.0
Inventory.ForbiddenTo BloodAngel
VisibleToPlayerClass BlackTemplar
+RESTRICTABSOLUTELY
Inventory.PickupSound "weapons/chaingun/pickup"
Inventory.PickupMessage "You got the HeavyBolter!"
Obituary "%o was mown down by %k's HeavyBolter."
AttackSound "none"
States
{
    Spawn:
        MGUN A -1
        Stop
    Ready:
        CHGS ABCD 1
        TNT1 A 0 A_PlaySound("weapons/chaingun/draw")
    ReadyLoop:
        CHAG A 1 A_WeaponReady(WRF_ALLOWZOOM)
        Goto ReadyLoop
    Select:
    Deselect:
        CHGS DCBA 1
        TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
        TNT1 A 1
        Wait
    NoAmmo:
        CHAE A 10 A_PlaySound("weapons/empty")
        Goto ReadyLoop
            
    Fire:
        TNT1 A 0 A_AlertMonsters
        CHAG BCD 0
        CHAG BCDBCD 0
        TNT1 A 0
    Hold:
        TNT1 A 0 A_Recoil(0.1)
        TNT1 A 0 A_SetAngle(random(1, -1) + angle)
        TNT1 A 0 A_SetPitch(-0.4 + pitch)
        
        //Main firing loop
        TNT1 A 0 A_PlaySound("weapons/chaingun/fire", 1)
        TNT1 A 0 A_Recoil(0.1)
        TNT1 A 0 A_FireCustomMissile("PlayerQuakeSmall", 0, 0, 0, 0)
        CHAF A 1 BRIGHT A_FireBullets(6, 4, 1, 9, "MachineGunBulletPuff", 1)
        TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
        TNT1 A 0 BRIGHT A_FireCustomMissile("MastermindTracer", random(-3,3), 0, 5, 5, 0, random(-3,3))
        TNT1 A 0 A_SpawnItemEx("BulletCasing", 17, 3, 35, 0, random(3,6), random(3,7))
        CHAF B 1
        TNT1 A 0 A_PlaySound("weapons/chaingun/fire", 1)
        CHAF J 1 BRIGHT A_FireBullets(6, 4, 1, 9, "MachineGunBulletPuff", 1)
        TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
        TNT1 A 0 A_SpawnItemEx("BulletCasing", 17, 3, 35, 0, random(3,6), random(3,7))
        CHAF H 1 A_SetAngle(random(1, -1) + angle)
        TNT1 A 0 A_ReFire
        
        //Cooldown
        CHAG A 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG B 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_Refire
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG C 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG D 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)    

        CHAG A 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG B 1 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG C 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG D 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)

        CHAG A 2
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG B 2
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG C 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG D 2 A_WeaponReady(WRF_ALLOWZOOM)
        TNT1 A 0 A_FireCustomMissile("MiniSmoke",0,0,0,0)
        CHAG ABCD 2 A_WeaponReady
        CHAG ABCD 3 A_WeaponReady
        goto ReadyLoop
    }
}
This problem happens to me with all the weapons not just this one but im using this one as an example
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Jarewill »

Both weapons replace the chaingun, but the last weapon to replace it is used.
What you need is to make an inventory item given to the BlackTemplar class to show what to spawn.
Go into DECORATE and add in the following line:

Code: Select all

Actor BlackTemplarToken : Inventory {}
Now for the BlackTemplar's class, add in:

Code: Select all

Player.StartItem "BlackTemplarToken"
After that remove the "replaces Chaingun" from the weapons and make a new actor that will spawn a weapon based on if the class has the token, example below:

Code: Select all

Actor NewChaingun replaces Chaingun{
States {
 Spawn:
 TNT1 A 0 NoDelay A_JumpIfInventory("BlackTemplarToken",1,"AltSpawn",AAPTR_PLAYER1)
 TNT1 A 0 A_SpawnItem("Heavybolter")
 Stop
 AltSpawn:
 TNT1 A 0 A_SpawnItem("BTHeavybolter")
 Stop
 }
}
Now, it's not perfect in any way, and I doubt it will work in multiplayer, but I hope it helps a bit.
User avatar
nekostuffing
Posts: 60
Joined: Sat Aug 31, 2019 8:08 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: giving weapons to specific player classes (BrutalDoomLit

Post by nekostuffing »

Jarewill wrote:Both weapons replace the chaingun, but the last weapon to replace it is used.
What you need is to make an inventory item given to the BlackTemplar class to show what to spawn.
Go into DECORATE and add in the following line:

Code: Select all

Actor BlackTemplarToken : Inventory {}
Now for the BlackTemplar's class, add in:

Code: Select all

Player.StartItem "BlackTemplarToken"
After that remove the "replaces Chaingun" from the weapons and make a new actor that will spawn a weapon based on if the class has the token, example below:

Code: Select all

Actor NewChaingun replaces Chaingun{
States {
 Spawn:
 TNT1 A 0 NoDelay A_JumpIfInventory("BlackTemplarToken",1,"AltSpawn",AAPTR_PLAYER1)
 TNT1 A 0 A_SpawnItem("Heavybolter")
 Stop
 AltSpawn:
 TNT1 A 0 A_SpawnItem("BTHeavybolter")
 Stop
 }
}
Now, it's not perfect in any way, and I doubt it will work in multiplayer, but I hope it helps a bit.
Yes this helps thank you, :D just a few questions. Can i use a starting item insted of a token, for example the BlackTemplar starting weapon is BTBolter
can i use it as this:

Code: Select all

TNT1 A 0 NoDelay A_JumpIfInventory("BTBolter",1,"AltSpawn",AAPTR_PLAYER1)
TNT1 A 0 A_SpawnItem("Heavybolter")
 Stop
 AltSpawn:
 TNT1 A 0 A_SpawnItem("BTHeavybolter")
 Stop
if i cant its no problem but i would like to know if its posible, now if i make a token do i have to name the token? fo example

Code: Select all

Actor BlackTemplarToken : Inventory {"Token1"}
or is that space left blank.
User avatar
CBM
Posts: 373
Joined: Wed Oct 09, 2019 3:39 am
Graphics Processor: nVidia with Vulkan support
Location: The Shores of Hell

Re: giving weapons to specific player classes (BrutalDoomLit

Post by CBM »

Jarewill wrote:Both weapons replace the chaingun, but the last weapon to replace it is used.
What you need is to make an inventory item given to the BlackTemplar class to show what to spawn.
Go into DECORATE and add in the following line:

Code: Select all

Actor BlackTemplarToken : Inventory {}
Now for the BlackTemplar's class, add in:

Code: Select all

Player.StartItem "BlackTemplarToken"
After that remove the "replaces Chaingun" from the weapons and make a new actor that will spawn a weapon based on if the class has the token, example below:

Code: Select all

Actor NewChaingun replaces Chaingun{
States {
 Spawn:
 TNT1 A 0 NoDelay A_JumpIfInventory("BlackTemplarToken",1,"AltSpawn",AAPTR_PLAYER1)
 TNT1 A 0 A_SpawnItem("Heavybolter")
 Stop
 AltSpawn:
 TNT1 A 0 A_SpawnItem("BTHeavybolter")
 Stop
 }
}
Now, it's not perfect in any way, and I doubt it will work in multiplayer, but I hope it helps a bit.

what if he did this instead ? :

Code: Select all

Actor DoomChainGun : Chaingun {}
Actor BAHeavybolter : Heavybolter {}

Actor NewChaingun replaces Chaingun{
States {
 Spawn:
 TNT1 A 0 NoDelay A_JumpIfInventory("BlackTemplarToken",1,"AltSpawn",AAPTR_PLAYER1)
 TNT1 A 0 NoDelay A_JumpIfInventory("BloodAngelToken",1,"AltSpawn",AAPTR_PLAYER1)
 TNT1 A 0 A_SpawnItem("DoomChainGun")
 Stop
 AltSpawnBT:
 TNT1 A 0 A_SpawnItem("BTHeavybolter")
 Stop
 AltSpawnBA:
 TNT1 A 0 A_SpawnItem("BAHeavybolter")
 Stop
 }
}
then everyone else than black templars and blood angels, will get the regular chaingun -but the pointer AAPTR_PLAYER1 needs to be something more generic so that all players can use it... hmm


there is always playernumber

https://zdoom.org/wiki/PlayerNumber


then we could do smth like this:

I am not sure if the below is actually valid decorate code and ... is just to indicate that the if blocks must be made for players 1 to 8

Code: Select all

if (PlayerNumber() = 1)
{
 TNT1 A 0 NoDelay A_JumpIfInventory("BlackTemplarToken",1,"AltSpawn",AAPTR_PLAYER1)
 TNT1 A 0 NoDelay A_JumpIfInventory("BloodAngelToken",1,"AltSpawn",AAPTR_PLAYER1)
}
...
if (PlayerNumber() = 8)
{
 TNT1 A 0 NoDelay A_JumpIfInventory("BlackTemplarToken",1,"AltSpawn",AAPTR_PLAYER8)
 TNT1 A 0 NoDelay A_JumpIfInventory("BloodAngelToken",1,"AltSpawn",AAPTR_PLAYER8)
}
assuming the max amount of players equals 8
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Void Weaver »

@CBM: it's absolutely noncence: PlayerNumber - only for ACS, and your syntax is wrong.

All of that you needed there is a some CustomInventory wrapper, without any tokens and ugly PLAYER# pointers:

Code: Select all

Actor NewChaingun : CustomInventory replaces Chaingun
{
States
{
Spawn:
MGUN A -1

Pickup:
TNT1 A 0 A_JumpIf(CheckClass("BlackTemplar"),2)
TNT1 A 0 A_GiveInventory("Heavybolter")
Stop
TNT1 A 0 A_GiveInventory("BTHeavybolter")
Stop
}
}
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Jarewill »

nekostuffing wrote:Can i use a starting item insted of a token
You sure can! The token is just an inventory item that does nothing outside of being a check of a player class.
Though keep in mind that weapons can be dropped if they don't have the "+INVENTORY.UNDROPPABLE" flag.
nekostuffing wrote:do i have to name the token?
Nope. That bracket is needed to input flags, properties, states, etc. even if no properties are present in the actor, so it needs to be kept blank
CBM wrote:what if he did this instead ?
Apologies! I assumed that there will only be two player classes and didn't think of regular doomguy being kept in.
Void Weaver wrote:All of that you needed there is a some CustomInventory wrapper, without any tokens and ugly PLAYER# pointers
Though, both weapons seem to have a different pickup lines and I don't think A_GiveInventory will print out the message of each weapon.
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Void Weaver »

Items received via A_GiveInventory wouldn't print out any pickup messages at all.
It should be specified by A_Log customized message for both pickup variants.

Ofc there is no any restrictions to use A_SpawnItemEx instead.
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Jarewill »

Hmmm, didn't know that was a possible function.
In that case, your method works better and it's multiplayer-friendly.
Though small question, what if one wants different pickup sprites for each weapon?
Edit: Actually nevermind, I'm just being dumb right now >_>
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Void Weaver »

Jarewill wrote:Though small question, what if one wants different pickup sprites for each weapon?
Edit: Actually nevermind, I'm just being dumb right now >_>
Actually that's a correct question, and no - this way isn't supposed to render different spawn sprites before picking up.
Honestly I don't see any way to render\spawn item(s) with different spawn sprites at the same randomspawner\spawn_spot replacement, which are depends on the user's class and takes into account presence of more than 1 playerclass in game. :\ I guess it's impossible at all, even for zscript.
User avatar
CBM
Posts: 373
Joined: Wed Oct 09, 2019 3:39 am
Graphics Processor: nVidia with Vulkan support
Location: The Shores of Hell

Re: giving weapons to specific player classes (BrutalDoomLit

Post by CBM »

Void Weaver wrote:@CBM: it's absolutely noncence: PlayerNumber - only for ACS, and your syntax is wrong.

All of that you needed there is a some CustomInventory wrapper, without any tokens and ugly PLAYER# pointers:

Code: Select all

Actor NewChaingun : CustomInventory replaces Chaingun
{
States
{
Spawn:
MGUN A -1 

Pickup:
TNT1 A 0 A_JumpIf(CheckClass("BlackTemplar"),2)
TNT1 A 0 A_GiveInventory("Heavybolter")
Stop
TNT1 A 0 A_GiveInventory("BTHeavybolter")
Stop
}
}

yearh.. I was not at all sure about the syntax in the last bit there

what about this:

Code: Select all

Actor NewChaingun replaces Chaingun
{
States
{
Spawn:
TNT1 A 0  A_Look
loop
idle:
TNT1 A 0  A_Look
loop
See:
TNT1 A 0 A_JumpIf(CheckClass("BlackTemplar"),"BT")
TNT1 A 1 A_SpawnItem("Heavybolter")
TNT1 A 1000 // spawn cooldown
goto idle
BT:
TNT1 A 1 A_SpawnItem("BTHeavybolter")
TNT1 A 1000 // spawn cooldown
goto idle
}
}
wouldnt this work in multiplayer, display custom sprites (since the spawner itself has no sprites) AND display pickup message ?

or if it should only spawn once:

Code: Select all

Actor NewChaingun replaces Chaingun
{
States
{
Spawn:
TNT1 A 0  A_Look
loop
See:
TNT1 A 0 A_JumpIf(CheckClass("BlackTemplar"),"BT")
TNT1 A 1 A_SpawnItem("Heavybolter")
stop
BT:
TNT1 A 1 A_SpawnItem("BTHeavybolter")
stop
}
}
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Void Weaver »

Your variants are pointless because:
a) CheckClass("BlackTemplar") wouldn't work without pointing pointer different from AAPTR_DEFAULT, and therefore:
b) the NewChaingun wouldn't spawn any weapon at all;
c) even if you define CheckClass("BlackTemplar",AAPTR_PLAYER1) the NewChaingun will spawn only 1 type of weapon, depends on which player class will be detected in first time, so no multiplayer compatible at all.

So, the CustomInventory wrappers are still needed for mplayer compatibility.
I guess that more smooth and smart solution would be next:

Code: Select all

Actor NewChaingun replaces Chaingun //It replaces all Chaingun spawn spots and immediately spawn a 2 CInventory wrappers
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItem("HeavybolterGiver",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
TNT1 A 0 A_SpawnItem("BTHeavybolterGiver",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
Stop
}
}

Actor HeavybolterGiver : CustomInventory //Both CustomInventory wrappers needed to prevent picking up weapon by restricted player class
{
+INVENTORY.RESTRICTABSOLUTELY
Inventory.RespawnTics 1000 //Will respawn after 1000 tics
Inventory.ForbiddenTo BlackTemplar
VisibleToPlayerClass BloodAngel
Inventory.PickupSound "weapons/chaingun/pickup"
Inventory.PickupMessage "You got the Minigun!"
States
{
Spawn:
MGUN A -1 //Both can presented by different spawn sprites, if any

Pickup:
TNT1 A 0 A_GiveInventory("Heavybolter")
Stop
}
}

Actor BTHeavybolterGiver : CustomInventory //Both CustomInventory wrappers needed to prevent picking up weapon by restricted player class
{
+INVENTORY.RESTRICTABSOLUTELY
Inventory.RespawnTics 1000 //Will respawn after 1000 tics
Inventory.ForbiddenTo BloodAngel
VisibleToPlayerClass BlackTemplar
Inventory.PickupSound "weapons/chaingun/pickup"
Inventory.PickupMessage "You got the HeavyBolter!"
States
{
Spawn:
MGUN A -1 //Both can presented by different spawn sprites, if any

Pickup:
TNT1 A 0 A_GiveInventory("BTHeavybolter")
Stop
}
}
User avatar
nekostuffing
Posts: 60
Joined: Sat Aug 31, 2019 8:08 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: giving weapons to specific player classes (BrutalDoomLit

Post by nekostuffing »

Wow! i didnt think i would get so many responses, THANKS GUYS! :D
I used the token method for now but i dont know if it will work when i add more player classes, i will try Void Weaver's method if it dosnt. However im not intrested in multiplayer at the moment only single player, i will need a multiplayer method in the future, but it will be a long time until then and it wont be exactly the same mod but a deathmatch version that will be especificaly for multiplayer only, but it will be a long time until i get working on that so i will focus on single player right now.
User avatar
CBM
Posts: 373
Joined: Wed Oct 09, 2019 3:39 am
Graphics Processor: nVidia with Vulkan support
Location: The Shores of Hell

Re: giving weapons to specific player classes (BrutalDoomLit

Post by CBM »

Void Weaver wrote:Your variants are pointless because:
a) CheckClass("BlackTemplar") wouldn't work without pointing pointer different from AAPTR_DEFAULT, and therefore:
b) the NewChaingun wouldn't spawn any weapon at all;
c) even if you define CheckClass("BlackTemplar",AAPTR_PLAYER1) the NewChaingun will spawn only 1 type of weapon, depends on which player class will be detected in first time, so no multiplayer compatible at all.

So, the CustomInventory wrappers are still needed for mplayer compatibility.
I guess that more smooth and smart solution would be next:

Code: Select all

Actor NewChaingun replaces Chaingun //It replaces all Chaingun spawn spots and immediately spawn a 2 CInventory wrappers
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SpawnItem("HeavybolterGiver",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
TNT1 A 0 A_SpawnItem("BTHeavybolterGiver",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
Stop
}
}

Actor HeavybolterGiver : CustomInventory //Both CustomInventory wrappers needed to prevent picking up weapon by restricted player class
{
+INVENTORY.RESTRICTABSOLUTELY
Inventory.RespawnTics 1000 //Will respawn after 1000 tics
Inventory.ForbiddenTo BlackTemplar
VisibleToPlayerClass BloodAngel
Inventory.PickupSound "weapons/chaingun/pickup"
Inventory.PickupMessage "You got the Minigun!"
States
{
Spawn:
MGUN A -1 //Both can presented by different spawn sprites, if any

Pickup:
TNT1 A 0 A_GiveInventory("Heavybolter")
Stop
}
}

Actor BTHeavybolterGiver : CustomInventory //Both CustomInventory wrappers needed to prevent picking up weapon by restricted player class
{
+INVENTORY.RESTRICTABSOLUTELY
Inventory.RespawnTics 1000 //Will respawn after 1000 tics
Inventory.ForbiddenTo BloodAngel
VisibleToPlayerClass BlackTemplar
Inventory.PickupSound "weapons/chaingun/pickup"
Inventory.PickupMessage "You got the HeavyBolter!"
States
{
Spawn:
MGUN A -1 //Both can presented by different spawn sprites, if any

Pickup:
TNT1 A 0 A_GiveInventory("BTHeavybolter")
Stop
}
}
very interesting indeed

it will allow the exactly one blood angel player and the exactly one black templar player to both get a weapon if I am not mistaken?
User avatar
CBM
Posts: 373
Joined: Wed Oct 09, 2019 3:39 am
Graphics Processor: nVidia with Vulkan support
Location: The Shores of Hell

Re: giving weapons to specific player classes (BrutalDoomLit

Post by CBM »

nekostuffing wrote:Wow! i didnt think i would get so many responses, THANKS GUYS! :D
I used the token method for now but i dont know if it will work when i add more player classes, i will try Void Weaver's method if it dosnt. However im not intrested in multiplayer at the moment only single player, i will need a multiplayer method in the future, but it will be a long time until then and it wont be exactly the same mod but a deathmatch version that will be especificaly for multiplayer only, but it will be a long time until i get working on that so i will focus on single player right now.
thats the cool thing about this forum! :D

this technique for spawning different weapons for different playerclasses is something I will definetly try out on my own as well

I am looking forward to hearing more about your mod as I am also a huge WH40K fan!
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: giving weapons to specific player classes (BrutalDoomLit

Post by Void Weaver »

nekostuffing wrote:Wow! i didnt think i would get so many responses, THANKS GUYS! :D
I used the token method for now but i dont know if it will work when i add more player classes, i will try Void Weaver's method if it dosnt. However im not intrested in multiplayer at the moment only single player, i will need a multiplayer method in the future, but it will be a long time until then and it wont be exactly the same mod but a deathmatch version that will be especificaly for multiplayer only, but it will be a long time until i get working on that so i will focus on single player right now.
Glad to help. ^_^
But if you haven't interested in mplayer comptibility then Jarewill's solution or any of mine will be fit for your goal.
CBM wrote:it will allow the exactly one blood angel player and the exactly one black templar player to both get a weapon if I am not mistaken?
Yep, that is.
Post Reply

Return to “Scripting”