Given armor via puff not working when already armored.

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
Amuscaria
Posts: 6635
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Given armor via puff not working when already armored.

Post by Amuscaria »

I'm trying to fix a bug in HF's Soultaker alt-fire. It sends out BFG sprays that for each hit, is supposed to give 1 armor by the puff that is spawned on hit. This works fine when the player has no armor, but doesn't if I already have some. I tried playing with the MaxSaveAmount and SavePercentage, but to no avail. What am I missing?

Here's the code:

Armor Item:

Code: Select all

ACTOR SpiritArmor : BasicArmorBonus //Used for Soultaker only
{
   Armor.SaveAmount 1
   Armor.SavePercent 50
   Armor.MaxSaveAmount 200
   Inventory.Icon ARMRB0
   States
   {
   Spawn:
      ARMR A 1 
      Loop
   }
}
The puff:

Code: Select all

Actor SoulburnFX1 : SoultakerPuff1
{
   RENDERSTYLE ADD
   ALPHA 1.0
   DamageType wepsoul
   Translation "80:111=168:191"   
   -FORCEXYBILLBOARD
   States
   {
   Spawn:      
	  WRAI E 4 bright A_GiveToTarget("SpiritArmor",1)
      WRAI FGHIJ 3 bright A_Fadeout(0.1)
	  stop
   Crash:
      SEFX DEF 3 bright
      stop
      }
}
It seems I can't force the player to pick up the armor bonus even when +AlwaysPickup and +AutoActivate is inherited from the parent.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Given armor via puff not working when already armored.

Post by Blue Shadow »

Amuscaria wrote:This works fine when the player has no armor, but doesn't if I already have some.
This is odd. The puff actor should fail to give you the armor bonus, because it's making the call in the first state of its Spawn state sequence. As you may know, when an actor first spawns, it doesn't call its function in first state unless the [wiki=Actor_states#NoDelay]NoDelay[/wiki] keyword is set on that state.
User avatar
Amuscaria
Posts: 6635
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Given armor via puff not working when already armored.

Post by Amuscaria »

Oh wow. Wouldn't have saw the problem if you hadn't mentioned that. The actual reason was because the powered-up buff gave the armor in the XDeath state instead of the Spawn state, like the normal one. And I tested that powered-up puff when I had no armor and came to the wrong conclusion. Thanks. :P

Return to “Scripting”