Weapons and Pickup state
-
RobbyPants
- Posts: 37
- Joined: Wed Mar 13, 2013 12:53 am
Weapons and Pickup state
So I noticed that CustomInventory has a pickup state (and a drop state). Is there any way to hook that into a weapon to have it overwrite it's normal behavior?
I'm looking for a way to limit the number of guns a player can carry, and I was planning on giving them some custom items on pickup of the weapon, and having the pickup fail if they were already at maximum capacity.
Is this the right approach, or is there a better way to do it?
I'm looking for a way to limit the number of guns a player can carry, and I was planning on giving them some custom items on pickup of the weapon, and having the pickup fail if they were already at maximum capacity.
Is this the right approach, or is there a better way to do it?
RE: Weapons and Pickup state
You could always run an index in a global script with a weird script number so you'd likely not run into conflicts. It would be less messy than running dummy inventory item checks.
Last edited by Xenaero on Wed Mar 20, 2013 3:17 am, edited 1 time in total.
-
TheMisterCat
- Posts: 79
- Joined: Mon Jun 04, 2012 2:21 pm
- Location: NZ
RE: Weapons and Pickup state
http://zdoom.org/wiki/Actor_properties#Player
Sorry if this is a bit messy, but I had a go at quickly writing how I think it should work. Here's the body of ACS
and just have 'fake' pickups which run the script (passing the array index of the weapon type)
bind the drop_weapon script as a puke and disable weapon dropping flag
Code: Select all
actor DoomPlayer : PlayerPawn
{
Player.WeaponSlot 1, Gun1, Gun2, Gun3...
Player.WeaponSlot 2, Gun1, Gun2, Gun3...
}
Code: Select all
#include "zcommon.acs"
#library "GunWeight"
#define MaxWeight 100
#define MaxPlayers 32
#define ptidoffset 500
#define PICKUP_WEAPON 100
#define SWITCH_WEAPON 101
#define DROP_WEAPON 102
int PlayerWeight[MaxPlayers];
#define MAX_WEAPONS 3
int WeaponWeights[MAX_WEAPONS] = { 30, 45, 50 };
str WeaponNames[MAX_WEAPONS] = { "Gun1", "Gun2", "Gun3" };
str WeaponPickups[MAX_WEAPONS] = { "Gun1Pickup", "Gun2Pickup", "Gun3Pickup" };
//returns the index number of the currently held weapon
function int CheckPlayerWeapon ( void )
{
for(int i = 0; i < MAX_WEAPONS; i++)
{
if(CheckWeapon(WeaponNames[i]))
{ return i; }
}
return -1;
}
Script PICKUP_WEAPON (int GunType)
{
if(PlayerWeight[PlayerNumber()] + WeaponWeights[GunType] < MaxWeight)
{
PlayerWeight[PlayerNumber()] += WeaponWeights[GunType];
GiveInventory(WeaponNames[GunType], 1);
SetWeapon(WeaponNames[GunType]);
}
else
{
Print(s:"Too heavy!");
}
}
Script SWITCH_WEAPON (int GunType)
{
if((PlayerWeight[PlayerNumber()] - WeaponWeights[CheckPlayerWeapon()]) + WeaponWeights[GunType] < MaxWeight)
{
PlayerWeight[PlayerNumber()] -= WeaponWeights[CheckPlayerWeapon()];
PlayerWeight[PlayerNumber()] += WeaponWeights[GunType];
Spawn(WeaponPickups[CheckPlayerWeapon()], GetActorX(0) + cos(GetActorAngle(0))*32, GetActorY(0) + sin(GetActorAngle(0))*32, GetActorZ(0)+24.0);
TakeInventory(WeaponNames[CheckPlayerWeapon()], 1);
GiveInventory(WeaponNames[GunType], 1);
SetWeapon(WeaponNames[GunType]);
}
else
{
Print(s:"Too heavy!");
}
}
Script DROP_WEAPON (VOID)
{
PlayerWeight[PlayerNumber()] -= WeaponWeights[CheckPlayerWeapon()];
Spawn(WeaponPickups[CheckPlayerWeapon()], GetActorX(0) + cos(GetActorAngle(0))*32, GetActorY(0) + sin(GetActorAngle(0))*32, GetActorZ(0)+24.0);
TakeInventory(WeaponNames[CheckPlayerWeapon()], 1);
}
Code: Select all
Actor Gun1Pickup : CustomInventory
{
States
{
Spawn:
GUN1 A -1
stop
Pickup:
GUN1 A 1 ACS_Execute(100, 0, 0)
stop
}}
Actor Gun2Pickup : Gun1Pickup
{ States {
Pickup:
GUN2 A 1 ACS_Execute(100, 0, 1)
stop
}}
et cetera
-
RobbyPants
- Posts: 37
- Joined: Wed Mar 13, 2013 12:53 am
RE: Weapons and Pickup state
Thanks for that. I'm working on a modified version to try and get all the kinks out. That being said, I'm looking to replace all of the normal weapons on the map with the "pickup" customInventory versions of the weapons. Is there an easy way to replace them by using the same ID, or by making the spawn state of the weapon spawn the "pickup" instead?
-
TheMisterCat
- Posts: 79
- Joined: Mon Jun 04, 2012 2:21 pm
- Location: NZ
RE: Weapons and Pickup state
yeah, just have the spawn state spawn the pickup actor
-
RobbyPants
- Posts: 37
- Joined: Wed Mar 13, 2013 12:53 am
RE: Weapons and Pickup state
I'm having trouble getting it to spawn properly. If I encounter a regular shot gun (the actual gun), nothing is there, like it isn't spawning my shotgun pickup.
Here is the DECORATE code for my shotgun pickup:
Here is the Spawn state of the shot gun itself (with the original line commented out).
I'm not sure if I'm just messing stuff up with IDs, spawn IDs, using "stop" to end the spawn state, or what.
Here is the DECORATE code for my shotgun pickup:
Code: Select all
Actor Shot_gunPickup : M&P9Pickup 22021
{
Inventory.PickupMessage "Shot gun"
SpawnID 253
States
{
Spawn:
SHOT A -1
stop
Pickup:
SHOT A 0 A_JumpIfInventory("Shot_gun", 1, "GetAmmo")
SHOT A 1 ACS_Execute(100, 0, 1, 0, 0)
SHOT A 0 A_JumpIfInventory("WeaponCapacityFull", 1, "FailPickup")
stop
GetAmmo:
SHOT A 0 A_JumpIfInventory("Shell", 0, "FailPickup")
SHOT A 1 ACS_Execute(103, 0, 1, 3, 0)
stop
FailPickup:
SHOT A 1
fail
}
}Code: Select all
Spawn:
//SHOT A -1
SHOT A 1 A_SpawnItemEx("Shot_gunPickup", 0, 0, 0)
stop
-
RobbyPants
- Posts: 37
- Joined: Wed Mar 13, 2013 12:53 am
RE: Weapons and Pickup state
Ha! I figured it out!
That being said, I managed to bind a key to the drop script, but how do I remove the standard zdoom drop item command from the menu?
Code: Select all
Spawn:
SHOT A 15
SHOT A 0 A_SpawnItemEx("Shot_gunPickup", 0, 0, 0)-
TerminusEst13
- Retired Staff / Community Team Member
- Posts: 865
- Joined: Tue Jun 05, 2012 11:06 pm
RE: Weapons and Pickup state
You don't. Just tell people to use that instead, and pray they listen.
The Ranger - New class for HeXen.
ZDoom Wars - I drew some pictures.
Samsara - Some class-based mod I guess?
Metroid: Dreadnought - I am a dumb fanboy.
DemonSteele - ~come with me to anime world~
ZDoom Wars - I drew some pictures.
Samsara - Some class-based mod I guess?
Metroid: Dreadnought - I am a dumb fanboy.
DemonSteele - ~come with me to anime world~