CustomInventory Overlays - How To?!

Discuss all aspects of editing for ZDoom.
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.

CustomInventory Overlays - How To?!

Postby Nash » Tue Jan 10, 2017 8:35 am

Arookas wrote:The wiki says A_Overlay can be called by CustomInventory 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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: CustomInventory Overlays - How To?!

Postby kodi » Wed Jan 11, 2017 6:36 pm

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
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: CustomInventory Overlays - How To?!

Postby Nash » Thu Jan 12, 2017 12:33 am

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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: CustomInventory Overlays - How To?!

Postby kodi » Thu Jan 12, 2017 6:52 am

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 allExpand view
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
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: CustomInventory Overlays - How To?!

Postby Caligari87 » Thu Jan 12, 2017 2:29 pm

Oh lordy that's sexy.

8-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: CustomInventory Overlays - How To?!

Postby Nash » Fri Jan 13, 2017 12:32 am

kodi wrote:Edit:
Managed to get my overlays to synch with the real gun (the middle shotgun).


Nice! Minimal sauce pl0x?
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: CustomInventory Overlays - How To?!

Postby kodi » Fri Jan 13, 2017 3:57 am

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 allExpand view
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 allExpand view
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 allExpand view
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);
         }
   }
}
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013


Return to Editing (Archive)

Who is online

Users browsing this forum: No registered users and 2 guests