Need help with Inventory Use Error (DECORATE)

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!)
dawnyes_
Posts: 1
Joined: Wed Dec 07, 2022 5:46 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: Intel with Vulkan/Metal Support

Need help with Inventory Use Error (DECORATE)

Post by dawnyes_ »

So, I'm trying to make a Duke Nukem 3D styled kick attack using CustomInventory, and it works as long as I don't use A_Overlay, I get an error whenever I add an A_Overlay that hops over to a new state to display the kick sprites, here's my code.

Code: Select all

ACTOR QuickKickQ: CustomInventory
  {
   States
     {
	  Use:
	   KICK A 0 A_Overlay(-2, Kick)
	   Stop
	    Kick:
	     KICK A 2
	     KICK B 3 A_Punch
	     KICK C 2
		 Stop
	  }
   }
I would appreciate the help!
yum13241
Posts: 465
Joined: Mon May 10, 2021 8:08 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): EndeavorOS (basically Arch)
Graphics Processor: Intel with Vulkan/Metal Support

Re: Need help with Inventory Use Error (DECORATE)

Post by yum13241 »

"Stop" destroys the actor.
User avatar
ramon.dexter
Posts: 1343
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Need help with Inventory Use Error (DECORATE)

Post by ramon.dexter »

Here, take a look on how I've made an 9verlay weapon:

Code: Select all

class shoulderGun : wosPickup {	
	
	action void W_FireShoulderGun(bool useAmmo, bool doAlertMonsters) {        
		if (player == null) {
			return;
		}				
		player.mo.PlayAttacking2 ();
		let ownr2 = binderPlayer(invoker.owner);
		if (useAmmo) {
			ownr2.takeInventory("magazine_shoulderGun", 1);
		}		
		//  shoot action z blasterStaff lvl.2 altFire  /////////////////////////
		A_StartSound("weapons/shoulderGun/loop", CHAN_6, CHANF_DEFAULT, 1.0, false);                               
		//A_GunFlash();
		A_FireProjectile("greenArcLightning", 0.1*random(20,-20), false, -10, 20, 0, 0);
		A_SpawnItemEx("redFlashShort", 8, 0, 16, 0);
		if (doAlertMonsters) {
			A_AlertMonsters();
		}
		A_OverlayOffset(6, random(-2,2), random(-2,2), WOF_INTERPOLATE); //vypnout, protoze trese i hlavni zbrani
		////////////////////////////////////////////////////////////////////////
	}	
	
	Default {
		//$Category "Powerups/WoS"
		//$Title "ShoulderGun"
		
		+INVENTORY.INVBAR
		+INVENTORY.KEEPDEPLETED
		+INVENTORY.UNDROPPABLE
		+INVENTORY.UNTOSSABLE
		Tag "$TAG_shoulderGun";
		Inventory.Icon "I_SHCN";
		Inventory.Amount 1;
		Inventory.MaxAmount 1;	
		Inventory.InterhubAmount 1;
		Inventory.PickupMessage "$PICKUP_shoulderGun";
		Decal "BulletChip";
		Mass shoulderGunWeight;
		
	}
	
	States {
		Spawn:
			DUMM A -1;
			Stop;
		Use:
			TNT1 A 0 {
				if ( GetPlayerInput(MODINPUT_BUTTONS)&BT_USE ) { return resolveState("UseCheck"); }
				else if ( GetPlayerInput(MODINPUT_BUTTONS)&BT_USER1 && CountInv("shoulderGunCharger") && CountInv("magazine_shoulderGun") != 32 ) { return resolveState("UseReload"); }
				else { return resolveState("UseYes"); }
			}
			Fail;
		UseCheck:
			TNT1 A 0 A_Log(String.Format("\c[yellow][ %i%s", CountInv("magazine_shoulderGun"), "\c[yellow] pts ShoulderGun battery left ]"));
			Fail;
		UseReload:
			TNT1 A 0 {
				let item = self.FindInventory("shoulderGunCharger");
				if ( item != null ) {
					useInventory(item);
				} else {
					A_Log("\c[red][ You need ShoulderGun charger to reload your ShoulderGun! ]");
				}
			}
			Fail;
		UseYes:
			TNT1 A 0 {			
				statelabel nextstate = "remove";
				let ownr = binderPlayer(invoker.owner); 
				if (ownr && ownr.countInv("magazine_shoulderGun") > 0 ) {					
					nextstate = "startoverlay";						 									
				}
				else {
					A_Log("\c[red][ Not enough cells! ]");
					A_ClearOverlays(6, 6);
					return ResolveState("remove");					
				}
				return resolvestate(nextstate);
			}
			Fail;
	  
	  
		startoverlay:
			TNT1 A 0 {
				int layer = 6;
				A_OverLay(layer,"shootShoulderGun");
			}
			wait;
		shootShoulderGun:
			// animation remade with new model //////////////////////////////////////////
            DUMA ABCDEFGHIJ 1;
            DUMF AA 1;
            DUMF A 2;
            DUMF B 2 Bright W_FireShoulderGun(true, true);
            DUMF C 2 Bright W_FireShoulderGun(false, false);
            DUMF B 2 Bright W_FireShoulderGun(false, false);
            DUMF C 2 Bright W_FireShoulderGun(false, false);
            DUMF B 2 Bright W_FireShoulderGun(false, false);
            DUMF C 2 Bright W_FireShoulderGun(false, true);
            DUMA J 3;
            DUMA J 4 A_StartSound("weapons/shoulderGun/stop",6); //zrusit zvuk blesku
            DUMA J 5;
            DUMA J 3;
            DUMA J 3;
            DUMA JIH 4;
            DUMA GFEDCBA 1;
			TNT1 A 0 {
				return resolveState("remove");
			}
			/////////////////////////////////////////////////////////////////////////////
			/*SHCH JIHGFEDCBA 1;
			SHCH AA 1;
			//SHCN A 1 A_StartSound("weapons/shoulderGun/fire", CHAN_7, CHANF_DEFAULT, 1.0, false);
			SHCN A 2;
			SHCN I 2 Bright W_FireShoulderGun(true, true);
			SHCN J 2 Bright W_FireShoulderGun(false, false);
			SHCN I 2 Bright W_FireShoulderGun(false, false);
			SHCN J 2 Bright W_FireShoulderGun(false, false);
			SHCN I 2 Bright W_FireShoulderGun(false, false);
			SHCN J 2 Bright W_FireShoulderGun(false, true);
			SHCN B 3;
			SHCN C 3;
			SHCN D 4 A_StartSound("weapons/shoulderGun/stop",6); //zrusit zvuk blesku
			SHCN E 5;
			SHCN F 4;
			SHCN G 4;
			SHCN H 3;
			SHCN A 3;
			SHCH ABCDEFGHIJ 1;
			TNT1 A 0 {
				return resolveState("remove");
			}*/
		
		remove:
			TNT1 A 0 {
				A_ClearOverlays(6, 6);
			}
			Fail;
	}
}
User avatar
Ac!d
Posts: 326
Joined: Tue Apr 02, 2019 5:13 am
Location: France

Re: Need help with Inventory Use Error (DECORATE)

Post by Ac!d »

Code: Select all

ACTOR QuickKickQ : CustomInventory
{
	States
	{
	Pickup:
		TNT1 A 0 A_RailWait() //Required function to give the item to the inventory
		Stop
	Use:
		TNT1 A 0 A_Overlay(-2, "Kick", FALSE)
		Fail //Required to use Fail instead of Stop to prevent the item from being removed
	Kick:
		KICK A 2
		KICK B 3 A_Punch
		KICK C 2
		Stop
	}
}

Return to “Scripting”