Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Thfpjct

[QUESTION] Limit number of weapons.

Recommended Posts

It's kinda weird but in a basic way it goes like this:

 

Make an inventory item, that has the max amount of weapons you want the player to have. (I mean, if you want 3 max weapons, set Inventory.MaxAmount to 3)

For the purposes of this guide, Let's assume the inventory item i told you above is called WeaponLimitCount, and it's max amount is 3.


Now make a CustomInventory item for each weapon. This CustomInventory item is the actual pickup and works like this:

Actor insertsomenamehere : CustomInventory replaces insertreplacedweaponnamehere

{

states

{

Spawn:

//show a sprite here or something

 

Pickup:

TNT1 A 0 A_JumpIfInventory("WeaponLimitCount", 3, "DontPickup") //if the limit has been reached, don't do anything

TNT1 A 0 A_GiveInventory("WeaponLimitCount", 1) //if not, just give the weapon and add to the counter

TNT1 A 0 A_GiveInventory("ActualWeaponNameHere")

Stop

 

DontPickup:

TNT1 A 0 A_RailWait //does nothing, just stays there

Fail

}

}

Share this post


Link to post
On 9/8/2019 at 5:40 PM, -TDRR- said:

It's kinda weird but in a basic way it goes like this:

 

Make an inventory item, that has the max amount of weapons you want the player to have. (I mean, if you want 3 max weapons, set Inventory.MaxAmount to 3)

For the purposes of this guide, Let's assume the inventory item i told you above is called WeaponLimitCount, and it's max amount is 3.


Now make a CustomInventory item for each weapon. This CustomInventory item is the actual pickup and works like this:

Actor insertsomenamehere : CustomInventory replaces insertreplacedweaponnamehere

{

states

{

Spawn:

//show a sprite here or something

 

Pickup:

TNT1 A 0 A_JumpIfInventory("WeaponLimitCount", 3, "DontPickup") //if the limit has been reached, don't do anything

TNT1 A 0 A_GiveInventory("WeaponLimitCount", 1) //if not, just give the weapon and add to the counter

TNT1 A 0 A_GiveInventory("ActualWeaponNameHere")

Stop

 

DontPickup:

TNT1 A 0 A_RailWait //does nothing, just stays there

Fail

}

}

thanks alot!

btw do you know any way that i can make the weapon pickup not instant? like a need to press E on them to pick it up?

Share this post


Link to post
56 minutes ago, Thfpjct said:

thanks alot!

btw do you know any way that i can make the weapon pickup not instant? like a need to press E on them to pick it up?

You can do this by expanding on the method i gave you above. You will need an ACS script for this, but i'm going to write it for you. Though, you will need to compile it and put it into your mod.

 

//=====CODE STARTS HERE========

#library "PUTTHENAMEOFTHISFILEWITHOUTEXTENSIONHERE"

#include "zcommon.acs"

 

Script "Use_Button_Stuff" ENTER

{

int use; = GetPlayerInput(-1, INPUT_BUTTONS);

while(GetActorProperty(0, APROP_HEALTH) > 0)

{

delay(2);

use = GetPlayerInput(-1, INPUT_BUTTONS);

TakeInventory("PickupWeapons",1);

if(use & BT_USE) {GiveInventory("PickupWeapons",1);}

}

}

 

Script "Use_Button_Stuff2" RESPAWN {ACS_NamedExecuteAlways("Use_Button_Stuff", 0);}

//=====CODE ENDS HERE========

 

Make a new item called "PickupWeapons" (You can name it whatever you want, but change the name above too)

 

And on the code of the CustomInventory item do this:

//=====CODE STARTS HERE========

Actor insertsomenamehere : CustomInventory replaces insertreplacedweaponnamehere

{

states

{

Spawn:

//show a sprite here or something

 

Pickup: //New state, old pickup state was moved to DoPickup

TNT1 A 0 A_JumpIfInventory("PickupWeapons", 1, "DoPickup")

Fail

 

DoPickup:

TNT1 A 0 A_JumpIfInventory("WeaponLimitCount", 3, "DontPickup") //if the limit has been reached, don't do anything

TNT1 A 0 A_GiveInventory("WeaponLimitCount", 1) //if not, just give the weapon and add to the counter

TNT1 A 0 A_GiveInventory("ActualWeaponNameHere")

Stop

 

DontPickup:

TNT1 A 0 A_RailWait //does nothing, just stays there

Fail

}

}

//=====CODE ENDS HERE========

Share this post


Link to post
1 hour ago, -TDRR- said:

You can do this by expanding on the method i gave you above. You will need an ACS script for this, but i'm going to write it for you. Though, you will need to compile it and put it into your mod.

 

//=====CODE STARTS HERE========

#library "PUTTHENAMEOFTHISFILEWITHOUTEXTENSIONHERE"

#include "zcommon.acs"

 

Script "Use_Button_Stuff" ENTER

{

int use; = GetPlayerInput(-1, INPUT_BUTTONS);

while(GetActorProperty(0, APROP_HEALTH) > 0)

{

delay(2);

use = GetPlayerInput(-1, INPUT_BUTTONS);

TakeInventory("PickupWeapons",1);

if(use & BT_USE) {GiveInventory("PickupWeapons",1);}

}

}

 

Script "Use_Button_Stuff2" RESPAWN {ACS_NamedExecuteAlways("Use_Button_Stuff", 0);}

//=====CODE ENDS HERE========

 

Make a new item called "PickupWeapons" (You can name it whatever you want, but change the name above too)

 

And on the code of the CustomInventory item do this:

//=====CODE STARTS HERE========

Actor insertsomenamehere : CustomInventory replaces insertreplacedweaponnamehere

{

states

{

Spawn:

//show a sprite here or something

 

Pickup: //New state, old pickup state was moved to DoPickup

TNT1 A 0 A_JumpIfInventory("PickupWeapons", 1, "DoPickup")

Fail

 

DoPickup:

TNT1 A 0 A_JumpIfInventory("WeaponLimitCount", 3, "DontPickup") //if the limit has been reached, don't do anything

TNT1 A 0 A_GiveInventory("WeaponLimitCount", 1) //if not, just give the weapon and add to the counter

TNT1 A 0 A_GiveInventory("ActualWeaponNameHere")

Stop

 

DontPickup:

TNT1 A 0 A_RailWait //does nothing, just stays there

Fail

}

}

//=====CODE ENDS HERE========

Thanks man!

This ACS code it's kinda confusing to me now but i will try to learn it, thx again!

Share this post


Link to post
21 hours ago, Thfpjct said:

Ok for some reason when i Summon the Weapon pickup the game just crashes, maybe i did something wrong?

Here the "pk3" file to take less time.

COLT EXPERIMENTATION GUN.zip

Well, looking at the zip, you organized everything wrong. Make your project a .pk3 instead, and organize it like this:
Sprites go in a directory of the .pk3 called "sprites", Make sure to not include SS_XXXX markers in this folder.

Compiled ACS goes in "acs" (Not LOADACS, only the compiled file, which in this case is named "PICKUP")

 

After doing this, i got no crashes at all in ZDoom LE or LZDoom, so you just organized everything incorrectly and that was the cause of the crash.

Share this post


Link to post
22 hours ago, -TDRR- said:

Well, looking at the zip, you organized everything wrong. Make your project a .pk3 instead, and organize it like this:
Sprites go in a directory of the .pk3 called "sprites", Make sure to not include SS_XXXX markers in this folder.

Compiled ACS goes in "acs" (Not LOADACS, only the compiled file, which in this case is named "PICKUP")

 

After doing this, i got no crashes at all in ZDoom LE or LZDoom, so you just organized everything incorrectly and that was the cause of the crash.

thank you man, i didn't know the organization was really necessary.

Share this post


Link to post

Man this is given me fricking a headache, i did everything you said, but it keeps crashing, even in those source ports you mention.

every time i type "Summon Colt" to summon the pickup to test, the game just crashes, i even tried to begin from zero but it still crashing.

and sometimes when i am compiling the ACS he says that is something is wrong, something about with this that one character in bold, when i delete it it compiles, and other times it don't.

i losing my mind over this.

 

int use;= GetPlayerInput(-1, INPUT_BUTTONS);

 

Share this post


Link to post

Could you show the whole ACS source code? I can't tell you what's wrong with it if you only show me that one line. No reason to keep it private anyways.

 

Also, here's how the .pk3 file should be:

ColtExperiment.zip

Share this post


Link to post

#library "PICKUP"

#include "zcommon.acs"

 

Script "Use_Button_Stuff" ENTER

{

int use = GetPlayerInput(-1, INPUT_BUTTONS);

while(GetActorProperty(0, APROP_HEALTH) > 0)

{

delay(2);

use = GetPlayerInput(-1, INPUT_BUTTONS);

TakeInventory("PickupWeapons",1);

if(use & BT_USE) {GiveInventory("PickupWeapons",1);}

}

}

 

Script "Use_Button_Stuff2" RESPAWN{ACS_NamedExecuteAlways("Use_Button_Stuff", 0);}

 

 

I also tested the pk3 that you send, and it crashes for me. so i think the problem is something else.

Edited by Thfpjct

Share this post


Link to post
5 hours ago, Thfpjct said:

I also tested the pk3 that you send, and it crashes for me. so i think the problem is something else.

It's definitely your PC then. Not getting such crash even with GZD 4.2.1.

Share this post


Link to post
13 hours ago, -TDRR- said:

It's definitely your PC then. Not getting such crash even with GZD 4.2.1.

yeah, but anyway, thanks for the patience and help, at least i can make the "Weapon limit".

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×