[SOLVED] Problem with taking all armor from a player

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!)
PhantomDoom741
Posts: 12
Joined: Thu Nov 16, 2017 1:14 pm

[SOLVED] Problem with taking all armor from a player

Post by PhantomDoom741 »

So I'm trying to make an armor which, on pickup, "calibrates" the armor and health values, setting them both to 999 and after a few seconds it returns health to 100, clears the 999 armor and replaces it with another armor class. Then it sets the player speed to 1.25, everything while blending from black to green.
Everything works, except for the "clear and replace armor" part.
Here are the codes:

DECORATE

Code: Select all

ACTOR UACEAI_NonCalibratedArmor : BasicArmorPickup //999 Armor
{
  Armor.SaveAmount 999
  Inventory.MaxAmount 1
  Inventory.Amount 1
}

ACTOR UACEAI_NonCalibratedHealth : Health //999 health
{
  Inventory.MaxAmount 999
  Inventory.Amount 999
}

ACTOR UACEAI_ECArmorPickup : CustomInventory 31998 //The pickup
{
  Inventory.PickupMessage ""
  Inventory.Amount 1
  Inventory.MaxAmount 1
  +AUTOACTIVATE
  States
  {
  Spawn:
	ECAR A 10
	ECAR A 5 Bright
	Loop
  Pickup:
	TNT1 A 0 A_GiveInventory("UACEAI_ECArmorStartup") //Gives a "fake weapon" which displays the animation and executes the stuff.
	TNT1 A 0 ACS_NamedExecuteAlways("UACEAI_ArmorStartup") //Sets weapon to the animation.
	Stop
  }
}

ACTOR UACEAI_ECArmor : BasicArmorPickup //The armor that should replace the 999 one, but for some reason doesn't.
{
  Armor.SaveAmount 150
  Armor.SavePercent 40
  Inventory.Amount 1
  Inventory.MaxAmount 200
}

ACTOR UACEAI_ECArmorStartup : Weapon //The "fake weapon" which executes the code and blends the screen.
{
  Inventory.PickupMessage ""
  +WEAPON.NOALERT
  Tag "ARMOR STARTING UP..."
  States
  {
  Select:
	TNT1 A 0
	Goto Ready
  Deselect:
  Ready:
	TNT1 A 0 A_GunFlash
	TNT1 A 0 SetPlayerProperty(0,1,PROP_TOTALLYFROZEN) //Prevents the player from moving, looking and shooting
	TNT1 A 0 A_GiveInventory("UACEAI_NoncalibratedArmor") //Gives 999 armor
	TNT1 A 0 A_GiveInventory("UACEAI_NoncalibratedHealth") //Gives 999 health
	TNT1 A 0 A_Print("\cpShield and health values calibration...")
	TNT1 A 175 //Long Delay
	TNT1 A 0 A_TakeInventory("UACEAI_NoncalibratedArmor") //Here's the broken part. The function doesn't take the armor.
	TNT1 A 0 ACS_NamedExecuteAlways("UACEAI_ResetHealth") //Resets health
	TNT1 A 10 //Short Delay
	TNT1 A 0 A_GiveInventory("UACEAI_ECArmor") //This should give the final armor, but doesn't, as the 999 armor value's higher than the other armor's
	TNT1 A 0 A_Print("\cpCalibration complete. Activating movement functions...")
	TNT1 A 105 //Yet another delay
	TNT1 A 0 ACS_NamedExecuteAlways("UACEAI_Speed125") //Increases speed
	TNT1 A 0 SetPlayerProperty(0,0,PROP_TOTALLYFROZEN) //Player is allowed to move, shoot, look
	TNT1 A 0
	TNT1 A 1 A_TakeInventory("UACEAI_ECArmorStartup") //Takes the animation weapon
	Goto Deselect
  Fire:
	TNT1 A 0
	Goto Ready
  Flash:
	TNT1 A 291 A_SetBlend("Black", 0.9, 290, "Green", 0.9) //Blends
	Goto LightDone
  }
}
ACS

Code: Select all

#library "uaceai_functions"
#include "zcommon.acs"

script "UACEAI_ResetHealth" (void)
{
	SetActorProperty(0, APROP_HEALTH, 100);
}

script "UACEAI_Speed125" (void)
{
	SetActorProperty(0, APROP_SPEED, 1.25);
}

script "UACEAI_ArmorStartup" (void) //Sets weapon to the animation
{
	SetWeapon("UACEAI_ECArmorStartup");
}
How can I fix this?
Last edited by PhantomDoom741 on Wed Sep 05, 2018 8:09 am, edited 1 time in total.
Blue Shadow
Posts: 5032
Joined: Sun Nov 14, 2010 12:59 am

Re: Problem with taking all armor from a player

Post by Blue Shadow »

PhantomDoom741 wrote:

Code: Select all

TNT1 A 0 A_TakeInventory("UACEAI_NoncalibratedArmor") //Here's the broken part. The function doesn't take the armor.
Replace "UACEAI_NoncalibratedArmor" with "[wiki=Classes:BasicArmor]BasicArmor[/wiki]".
PhantomDoom741
Posts: 12
Joined: Thu Nov 16, 2017 1:14 pm

Re: Problem with taking all armor from a player

Post by PhantomDoom741 »

Blue Shadow wrote:
PhantomDoom741 wrote:

Code: Select all

TNT1 A 0 A_TakeInventory("UACEAI_NoncalibratedArmor") //Here's the broken part. The function doesn't take the armor.
Replace "UACEAI_NoncalibratedArmor" with "[wiki=Classes:BasicArmor]BasicArmor[/wiki]".
Thank you! :D :D :D

Return to “Scripting”