CustomInventory Overlays - How To?!

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Nash
 
 
Posts: 17422
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

CustomInventory Overlays - How To?!

Post by Nash »

Arookas wrote:The wiki says [wiki]A_Overlay[/wiki] can be called by [wiki]CustomInventory[/wiki] classes, but goes on to say exactly nothing about how this is done. Would anyone happen to know exactly how I go about doing that? Placing the psprite states in the CustomInventory doesn't give me access to all the Weapon code pointers that make psprites actually useful, and defining the states in the weapon or player doesn't seem to work. Am I supposed to call A_Overlay in the Pickup state? Do I need to give it a Use state that always fails so it stays in the inventory?
This was never answered and I have no idea how to do this, too. Please help. Preferrably a minimal working example.

ALSO:

Can someone teach me how would you sync the animation between the actual weapon sprite, and the CustomInventory overlays. They must both play the exact same animation.
User avatar
kodi
 
 
Posts: 1351
Joined: Mon May 06, 2013 8:02 am

Re: CustomInventory Overlays - How To?!

Post by kodi »

I'm very interested as well. Your post in the zscript thread made it sound like you had some success, but since this thread isn't marked as [SOLVED] I assume there's still issues. If you could provide a barebones zscript definition for an inventory item with an interactive overlay (if you've indeed succeded in doing that) I'd very much like to experiment a bit.
Nash wrote:Can someone teach me how would you sync the animation between the actual weapon sprite, and the CustomInventory overlays. They must both play the exact same animation.
I think you could give the playerpawn a "WeaponState" or whatever StateLabel variable which is set in every state of the actual weapon, then have a copy of each of these states as an overlay in each inventory item. At the end of each overlay state you'd jump to the next with Return Resolvstate () and a lookup for the owners WeaponState variable.
User avatar
Nash
 
 
Posts: 17422
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: CustomInventory Overlays - How To?!

Post by Nash »

Yeah I didn't mark this thread as [Solved] yet because

A) I don't really know WTF I was doing
B) I don't understand at all how to sync animations between all the overlays
User avatar
kodi
 
 
Posts: 1351
Joined: Mon May 06, 2013 8:02 am

Re: CustomInventory Overlays - How To?!

Post by kodi »

Well here's a plasma gun that runs on custom inventory overlays if that helps :P
Edit: I'll see if I can work out a synching system that works well. This is fun!

Code: Select all

class extraplasma : custominventory
{

	default
	{
		Inventory.Amount 1;
		inventory.maxamount 50;
		+INVENTORY.ALWAYSPICKUP;
		+INVENTORY.AUTOACTIVATE;
	}
	
	states 
	{	
		use:
			TNT1 A 0
			{
				statelabel nextstate = "remove";
				let ownr = doomplayer(invoker.owner); 
				if (ownr)                            
				{
					nextstate = "startoverlay";
				}
			return resolvestate(nextstate);
			}
			stop;
		
		remove:
			stop;
		
		startoverlay:
			TNT1 A 0
			{
				int layer = 5;
				A_OverLay(layer,"plasmaready");
				A_OverlayOffset(layer,0,32,WOF_KEEPX);
			}
			wait;
			
		plasmaready:
		PLSG A 1 A_jumpIf(getplayerinput(INPUT_BUTTONS)&BT_ATTACK,"shoot");
		loop;
		
		shoot:
		PLSF A 2 bright;
		TNT1 A 0 A_FireCustomMissile("plasmaball",frandom(-10.0,10.0));
		PLSF B 2 bright;
		PLSF A 2 bright;
		PLSG A 4;
		goto plasmaready;
		
		
		Spawn:
			TNT1 A -1;
			Stop;
	}

}
Edit:
Managed to get my overlays to synch with the real gun (the middle shotgun).
>>Video here<<
User avatar
Caligari87
Admin
Posts: 6167
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

Re: CustomInventory Overlays - How To?!

Post by Caligari87 »

Oh lordy that's sexy.

8-)
User avatar
Nash
 
 
Posts: 17422
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: CustomInventory Overlays - How To?!

Post by Nash »

kodi wrote: Edit:
Managed to get my overlays to synch with the real gun (the middle shotgun).
Nice! Minimal sauce pl0x?
User avatar
kodi
 
 
Posts: 1351
Joined: Mon May 06, 2013 8:02 am

Re: CustomInventory Overlays - How To?!

Post by kodi »

Full sauce; minimal function ! :joker:

Edit: Guess it was a silly way of doing it. If you find a better one please post that tutorial you mentioned at some point :)

Player:

Code: Select all

Class SpecMarine : DoomPlayer
{
    statelabel wepstate; //you need to set this to something by overriding postbeginplay if you want the overlay-weapons to work before you ready a weapon-weapon :P

}
weapon:

Code: Select all

class overlayshotgun : shotgun replaces shotgun
{
	default
	{
	weapon.ammouse 0;
	}

	states
	{	
	Ready:
		TNT1 A 0
        {
            let ownr = SpecMarine(invoker.owner); // Auto casts to the specified actor.
            if (ownr)                             // Make sure it exists.
            {
				ownr.wepstate = "wepready";                   
			}
			else
			{
				a_log("wepstate ready set fail");
			}
        }
		goto ready2;
		
	ready2:
		SHTG A 1 A_WeaponReady;
		Loop;
		
	Deselect:
		SHTG A 1 A_Lower;
		Loop;
		 
	Select:
		SHTG A 1 A_Raise;
		Loop;
	
	Fire:
		SHTG A 0
		{
            let ownr = SpecMarine(invoker.owner); 
            if (ownr)                            
            {
                ownr.wepstate = "wepfire";                   
			}
			else
			{
				a_log("wepstate fire set fail");
			}
        }
		SHTG A 3;
		SHTG A 7; 
		SHTG A 0 A_FireBullets (5.6, 0, 7, 5, "BulletPuff");
		SHTG A 0 A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
		SHTG BC 5;
		SHTG D 4;
		SHTG CB 5;
		SHTG A 3;
		SHTG A 7;
		Goto Ready;
	
	Spawn:
		SHOT A -1;
		Stop;

	}
}
overlay items:

Code: Select all

class extrashotgun : custominventory
{
	statelabel nextstate;
	default
	{
		Inventory.Amount 1;
		inventory.maxamount 50;
		+INVENTORY.ALWAYSPICKUP;
		+INVENTORY.AUTOACTIVATE;
	}

	states
	{
		use:
			TNT1 A 0
			{
				statelabel initstate = "remove";
				let ownr = specmarine(invoker.owner); 
				if (ownr)                            
				{
					initstate = "startoverlay";
				}
				return resolvestate(initstate);
			}
			stop;
		
		remove:
			stop;
		
		startoverlay:
			TNT1 A 0
			{
				int layer = 5;
				A_OverLay(layer,"wepready");
				A_OverlayOffset(layer,64,32);
			}
			wait;
			
	wepready: 

		SHTG A 1; 
		SHTG A 0
        {
			let ownr = SpecMarine(invoker.owner); 
            if (ownr)                             
            {
                invoker.nextstate = ownr.wepstate;                  
            }
		return resolvestate (invoker.nextstate);
        }
		SHTG A 1 A_log("Overlay Wepready state error");
		stop;
		
	wepfire: //this must has the exact same amount of frames as the corresponding state in the actual weapon.
		SHTG A 3;
		SHTG A 7; 
		SHTG A 0 A_FireBullets (5.6, 0, 7, 5, "BulletPuff");
		SHTG A 0 A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
		SHTG BC 5;
		SHTG D 4;
		SHTG CB 5;
		SHTG A 3;
		SHTG A 7;
		SHTG A 0
        {
            let ownr = SpecMarine(invoker.owner); 
            if (ownr)                           
            {
                invoker.nextstate = ownr.wepstate;                   
            }
		return resolvestate (invoker.nextstate);
        }
		TNT1 A 0 A_log("wepfire resolvestate fail");
		stop;

	Spawn:
		SHOT A -1;
		Stop;

	}
}
 
class extrashotgun2 : extrashotgun 
{
	states
	{
	startoverlay:
			TNT1 A 0
			{
				int layer = 6; 
				//i tried putting random(5,500) here in the 
				//above item, but several instances of the same
				//class of custom inventory item with overlays
				//do not work together :(
				A_OverLay(layer,"wepready");
				A_OverlayOffset(layer,-64,32);
			}
	}
}

Return to “Editing (Archive)”