Page 1 of 1

Picking up weapons by pressing a button

Posted: Tue May 24, 2016 2:44 pm
by Mayrine
Hi!!

Well in my mod there are TONS of guns, this becomes rly annoying when you dont want a weapon anymore and maybe monsters drop them (like shotgunguy's shotgun) so occasionally you will be picking up it accidentally... what i wanted is something to make weapons unable to be picked up unless you press a button.

I don't have any idea of how to make this... any help would be REALLY appreciated.

Re: Picking up weapons by pressing a button

Posted: Tue May 24, 2016 3:05 pm
by Matt
The simplest way to do it is to have a constantly looping ACS script that calls [wiki]GetPlayerInput[/wiki], checks to see if the player is pressing Use, and if they are, give them a custominventory item that sets them to be able to pick up items, and if they're not hitting Use, do the opposite:

Code: Select all

//ACS
	if (GetPlayerInput(-1,MODINPUT_BUTTONS) & BT_USE){
		GiveInventory("CanPickUpItems",1);
	}else{
		GiveInventory("CantPickUpItems",1);
	}

//DECORATE
actor CanPickUpItems : CustomInventory
{
	states
	{
	pickup:
		TNT1 A 0 A_ChangeFlag("pickup",1)
		fail
	}
}
actor CantPickUpItems : CustomInventory
{
	states
	{
	pickup:
		TNT1 A 0 A_ChangeFlag("pickup",0)
		fail
	}
}
With this, you have to be holding down the use key while running over something in order to pick it up.

The other option is to replace every pickup with a switchable decoration, which lets you literally use something to pick it up in the style of a modern FPS, but it is extremely tedious and a bit complicated to set up, and will break compatibility with virtually every other gameplay/weapon mod.

Re: Picking up weapons by pressing a button

Posted: Tue May 24, 2016 5:14 pm
by Mayrine
I dont know what am i doing wrong but the ACS is not working (sorry i almost dont know anything about ACS)

Re: Picking up weapons by pressing a button

Posted: Tue May 24, 2016 5:41 pm
by Matt
Here's the beginner's guide to get you started. Setting up DoomBuilder/ACC/etc. is something perhaps best left to someone who isn't me to explain since I have a bit of a bad history of trying to get things working.

A full ACS file to do this would be something more like this:

Code: Select all

#library "YOURPROJECTNAME"
#include "zcommon.acs"
  script "watchforspace" ENTER{
   if (GetPlayerInput(-1,MODINPUT_BUTTONS) & BT_USE){
      GiveInventory("CanPickUpItems",1);
   }else{
      GiveInventory("CantPickUpItems",1);
   }
   delay(1);
   restart;
  }
Then you'd need a LOADACS lump that is a text file with YOURPROJECTNAME (i.e., whatever you're calling this ACS thing) written in it. That will tell ZDoom to load that ACS script on every level.

Re: Picking up weapons by pressing a button

Posted: Sat May 28, 2016 12:18 pm
by Raziel236
If you have your own weapons set and don't want the doom weapons then shouldn't you replace them?

Re: Picking up weapons by pressing a button

Posted: Sun May 29, 2016 11:48 am
by Accensus
@Vae's code: Isn't the code supposed to be this:

Code: Select all

else { TAKEinventory("CanPickUpItems", 1) }
Doesn't make much sense in its current form.

EDIT: Goddamnit, missed the T in CantPickupItems. My mistake.

Re: Picking up weapons by pressing a button

Posted: Mon May 30, 2016 10:22 pm
by Murix
Wooooooooo.... right this looks like it's going to be fun to learn. Trial and error here I come.

Re: Picking up weapons by pressing a button

Posted: Fri Jun 03, 2016 1:35 pm
by LastManonEarth
This is related with intention I always had: limited arsenal. Limited weight to pick wepons. i.e You can pick 4 light weapons, or 2 heavy ones, 3 mid-sized etc.
Drop and pick buttons will be needed.

Re: Picking up weapons by pressing a button

Posted: Fri Jun 03, 2016 8:58 pm
by The Zombie Killer
Note that A_CheckProximity is in ACS now, although there isn't a wiki page yet. So you can use that instead of decorate item hacks now

bool CheckProximity(int tid, str class, double distance, int count = 1, int flags = 0, int ptr = AAPTR_DEFAULT)