Picking up weapons by pressing a button

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.
Locked
User avatar
Mayrine
Posts: 15
Joined: Mon Mar 28, 2016 6:25 pm

Picking up weapons by pressing a button

Post 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.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Picking up weapons by pressing a button

Post 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.
User avatar
Mayrine
Posts: 15
Joined: Mon Mar 28, 2016 6:25 pm

Re: Picking up weapons by pressing a button

Post by Mayrine »

I dont know what am i doing wrong but the ACS is not working (sorry i almost dont know anything about ACS)
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Picking up weapons by pressing a button

Post 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.
User avatar
Raziel236
Posts: 313
Joined: Tue Jul 02, 2013 7:26 pm
Contact:

Re: Picking up weapons by pressing a button

Post by Raziel236 »

If you have your own weapons set and don't want the doom weapons then shouldn't you replace them?
User avatar
Accensus
Banned User
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: Picking up weapons by pressing a button

Post 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.
User avatar
Murix
Posts: 135
Joined: Wed Mar 30, 2016 11:10 pm
Location: On my chair
Contact:

Re: Picking up weapons by pressing a button

Post by Murix »

Wooooooooo.... right this looks like it's going to be fun to learn. Trial and error here I come.
User avatar
LastManonEarth
Posts: 44
Joined: Mon Apr 25, 2016 4:25 pm

Re: Picking up weapons by pressing a button

Post 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.
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: Picking up weapons by pressing a button

Post 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)
Locked

Return to “Editing (Archive)”