New player class ignores A_TakeInventory()

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!)
Post Reply
User avatar
rapfamily4
Posts: 6
Joined: Wed Jul 01, 2015 3:45 pm
Location: Italy

New player class ignores A_TakeInventory()

Post by rapfamily4 »

Hello!

I was working on my mod today and I decided to check the custom player class. While some tests I noticed all the statements involving A_TakeInventory have been costantly ignored. I don't know what's actually happening here.

Here's the DECORATE script:

Code: Select all

ACTOR SSPlayer : DoomPlayer
{
	Speed 0.7
	Player.ForwardMove 1, 1
	Player.SideMove 1.25, 1.25
	Player.JumpZ 8.5
	Player.ViewHeight 48
	Gravity 0.9
	Health 100
	Radius 16
	Height 56
	Mass 100
	PainChance 255
	Player.DisplayName "Olayana"
	Player.CrouchSprite "PLYC"
	Player.StartItem "PlasmaPistol"
	Player.StartItem "Clip", 30
	Player.StartItem "A_Melee"
	Player.StartItem "A_MeleeCancel"
	Player.StartItem "A_Boost"
	Player.StartItem "A_BoostCancel"
	Player.WeaponSlot 1, PlasmaPistol
	Player.WeaponSlot 2, BeamRifle
	Player.WeaponSlot 3, DispersionCannon
	Player.WeaponSlot 4, VeloxRifle

	States
	{
		Spawn:
			PLAY A 1 A_TakeInventory("BR_Charge", 1)
			PLAY A 0 A_TakeInventory("PlasmaBoost", 1)
			PLAY A 0 A_TakeInventory("BeamBoost", 1)
			PLAY A 0 A_TakeInventory("DispersionBoost", 1)
			PLAY A 0 A_TakeInventory("VeloxBoost", 1)
		Loop
		See:
			PLAY B 1 A_TakeInventory("BR_Charge", 1)
			PLAY B 0 A_TakeInventory("PlasmaBoost", 1)
			PLAY B 0 A_TakeInventory("BeamBoost", 1)
			PLAY B 0 A_TakeInventory("DispersionBoost", 1)
			PLAY B 0 A_TakeInventory("VeloxBoost", 1)
		Goto See
		Pain:
			PLAY G 1 A_TakeInventory("BR_Charge", 1)
			PLAY G 0 A_TakeInventory("PlasmaBoost", 1)
			PLAY G 0 A_TakeInventory("BeamBoost", 1)
			PLAY G 0 A_TakeInventory("DispersionBoost", 1)
			PLAY G 0 A_TakeInventory("VeloxBoost", 1)
			PLAY G 0 A_Pain
			PLAY G 1 A_TakeInventory("BR_Charge", 1)
			PLAY G 0 A_TakeInventory("PlasmaBoost", 1)
			PLAY G 0 A_TakeInventory("BeamBoost", 1)
			PLAY G 0 A_TakeInventory("DispersionBoost", 1)
			PLAY G 0 A_TakeInventory("VeloxBoost", 1)
		Goto Spawn
		Death:
			PLAY H 0 A_PlayerSkinCheck("AltSkinDeath")
		Death1:
			PLAY H 10
			PLAY I 10 A_PlayerScream
			PLAY J 10 A_NoBlocking
			PLAY KLM 10
			PLAY N -1
		Stop
		XDeath:
			PLAY O 0 A_PlayerSkinCheck("AltSkinXDeath")
		XDeath1:
			PLAY O 5
			PLAY P 5 A_XScream
			PLAY Q 5 A_NoBlocking
			PLAY RSTUV 5
			PLAY W -1
		Stop
		AltSkinDeath:
			PLAY H 6
			PLAY I 6 A_PlayerScream
			PLAY JK 6
			PLAY L 6 A_NoBlocking
			PLAY MNO 6
			PLAY P -1
		Stop
		AltSkinXDeath:
			PLAY Q 5 A_PlayerScream
			PLAY R 0 A_NoBlocking
			PLAY R 5 A_SkullPop
			PLAY STUVWX 5
			PLAY Y -1
		Stop
	}
}
And here's the MAPINFO script:

Code: Select all

GameInfo
{
   PlayerClasses = "SSPlayer"
}
Thank you in advance! :D
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: New player class ignores A_TakeInventory()

Post by ramon.dexter »

So, I think the problem is that you are trying to remove things from player, while I dont see where are the mentioned items being assigned to player.
User avatar
rapfamily4
Posts: 6
Joined: Wed Jul 01, 2015 3:45 pm
Location: Italy

Re: New player class ignores A_TakeInventory()

Post by rapfamily4 »

Hi, thanks!

Well, the items are assigned from the weapon the player uses (or rather, from the weapon's actor). Those items are a counter for a boost, one for each weapon. For instance, the VeloxBoost is for the Velox Rifle. Now, I'll show you the code of the latter. This is a system I used for all the other weapons. You can find A_GiveInventory in the Boost state.

Code: Select all

ACTOR VeloxRifle : WeaponBase replaces Shotgun
{
	Weapon.AmmoUse1 1
	Weapon.AmmoGive1 8
	Weapon.AmmoType1 "Shell"
	Weapon.AmmoUse2 1
	Weapon.AmmoGive2 0
	Weapon.AmmoType2 "Shell"
	
	States
	{
		WeaponReady:
		Ready:
			SHTG A 0 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_WeaponReady
		Loop
		Deselect:
			SHTG A 0 A_Lower
			SHTG A 1 A_Lower
		Loop
		Select:
			SHTG A 0 A_Raise
			SHTG A 1 A_Raise
		Loop
		Fire:
			SHTG A 0 A_JumpIfInventory("VeloxBoost", 1, "BoostFire")
			SHTG A 6 A_RailAttack(50, 0, 1, "#8ebfd1", "lightblue", RGF_NOPIERCING | RGF_FULLBRIGHT, 0, none, 0, 0, 10000, 12, 0.5, 1.5)
			SHTG BC 5
			SHTG D 4
			SHTG CB 1
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_ReFire
		Goto WeaponReady
		BoostFire:
			SHTG A 0 A_RailAttack(25, 0, 0, "none", "#ff6600", RGF_FULLBRIGHT, 0, none, 0, 0, 10000, 12, 0.5, 1.5)		
			SHTG A 6 A_RailAttack(50, 0, 1, "#ff9933", "none", RGF_NOPIERCING | RGF_FULLBRIGHT, 0, none, 0, 0, 10000, 12, 0.5, 1.5)
			SHTG BC 5
			SHTG D 4
			SHTG CB 1
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_ReFire
		Goto WeaponReady
		AltFire:
			SHTG A 0 A_JumpIfInventory("VeloxBoost", 1, "BoostAltFire")
			SHTG A 0 A_FireCustomMissile("VeloxThrustProjectile", 0, 1)
			SHTG A 15
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_ReFire
		Goto WeaponReady
		BoostAltFire:
			SHTG A 0 A_FireCustomMissile("BoostVeloxThrustProjectile", 0, 1)
			SHTG A 15
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_JumpIfInventory("IsBoost", 1, "Boost")
			SHTG A 1 A_JumpIfInventory("IsMelee", 1, "Melee")
			SHTG A 0 A_ReFire
		Goto WeaponReady
		Boost:
			SHTG A 1 A_JumpIfInventory("BasicArmor", 30, 1)
		Goto WeaponReady
			PUNG A 0 A_TakeInventory("BasicArmor", 30)
			PUNG B 18 A_PlaySound("DCCHARGE", 1)
			PUNG B 0 A_GiveInventory("VeloxBoost", 350)
			PUNG C 3 A_PlaySound("weapons/bfgx", 1)
		Goto WeaponReady
		Melee:
			PUNG A 0 A_JumpIfInventory("SuperMeleeCounter", 0, 3)
			PUNG A 0 A_JumpIfInventory("BasicArmor", 30, 1)
			Goto FireMelee
			PUNG A 0 A_GiveInventory("SuperMeleeCounter", 1)
			PUNG A 0 A_JumpIfInventory("SuperMeleeCounter", 0, 2)
			PUNG A 0 A_JumpIfInventory("SuperMeleeCounter", 1, 5)
			PUNG A 0 A_JumpIfInventory("SuperMeleeBeepDone", 1, 4)
			PUNG A 0 A_PlaySound("DCCHRGD", 1)
			PUNG A 0 A_GiveInventory("SuperMeleeBeepDone", 1)
			PUNG A 0 A_TakeInventory("BasicArmor", 30)
			PUNG A 0 A_JumpIfInventory("SuperMeleeFirstDone", 1, 3)
			PUNG A 0 A_PlaySound("DCCHARGE", 1, 2)
			PUNG A 0 A_GiveInventory("SuperMeleeFirstDone", 1)
			PUNG A 1
			PUNG A 0 A_JumpIfInventory("IsMelee", 1, "Melee")
		FireMelee:
			PUNG A 0 A_JumpIfInventory("SuperMeleeCounter", 0, "SuperMelee")
			PUNG B 0 A_StopSound(1)
			PUNG B 1 A_Recoil((-5)*cos(pitch))
			PUNG C 1 
			PUNG D 2 A_CustomPunch(25, true, 0, "BulletPuff", 70)
			PUNG C 4
			PUNG B 5
			PUNG B 0 A_TakeInventory("SuperMeleeCounter", 0)
			PUNG B 0 A_TakeInventory("SuperMeleeBeepDone", 0)
			PUNG B 0 A_TakeInventory("SuperMeleeFirstDone", 0)
			PUNG B 0 A_ReFire
		Goto WeaponReady
		SuperMelee:
			PUNG B 0 A_PlaySound("weapons/bfgx", 1)
			PUNG B 0 A_Recoil((-40)*cos(pitch))
			PUNG B 0 ThrustThingZ(0, 150*sin(pitch), 1, 0)                      //https://forum.zdoom.org/viewtopic.php?f=3&t=15222
			PUNG BCCDDDD 1 A_Explode(100, 100, XF_NOTMISSILE, true)
			PUNG C 4
			PUNG B 5
			PUNG B 0 A_TakeInventory("SuperMeleeCounter", 0)
			PUNG B 0 A_TakeInventory("SuperMeleeBeepDone", 0)
			PUNG B 0 A_TakeInventory("SuperMeleeFirstDone", 0)
			PUNG B 0 A_ReFire
		Goto WeaponReady
		Spawn:
			SHOT A -1
		Stop
	}
}
User avatar
rapfamily4
Posts: 6
Joined: Wed Jul 01, 2015 3:45 pm
Location: Italy

Re: New player class ignores A_TakeInventory()

Post by rapfamily4 »

Ok, solved! I only had to write ACTOR SSPlayer : PlayerPawn replaces DoomPlayer at the definition of the class actor. I'm not sure why it worked, though. Can someone please explain me what actually happened here?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: New player class ignores A_TakeInventory()

Post by Arctangent »

My first instinct is that it didn't work at all, but rather something you tried but didn't take note of is what eventually did it.

Also, this is a really inelegant way of removing token items. Something like an ACS script that loops while the player is alive or a ZScript Tick() override would probably do exactly what you want without mucking up the player's animations.
User avatar
rapfamily4
Posts: 6
Joined: Wed Jul 01, 2015 3:45 pm
Location: Italy

Re: New player class ignores A_TakeInventory()

Post by rapfamily4 »

Thank you for the advice!

I'll try to implement it through an ACS script.


EDIT: Sorry to bother you. How can I run an ACS script indipendently by the map?
Post Reply

Return to “Scripting”