Page 1 of 1
Keeping weapons in deathmatch?
Posted: Thu Jun 14, 2012 2:42 pm
by Ænima
Is there any way to force the behavior of sv_keepweapons in a deathmatch game so that players keep their weapons after dying? (like in coop)
It's because I'm making a mod where players must buy their weapons like in WolfTeam or Combat Arms.
I'd prefer to not have to make ACS arrays for every weapon to store whether a player has purchased a certain weapon. There has to be a simpler way.
RE: Keeping weapons in deathmatch?
Posted: Thu Jun 14, 2012 2:49 pm
by Theshooter7
Other than ACS or co-op mode hacks, no there isn't. :/ If Zandronum supports the RESPAWN script type you might be able to make something work with that, but you'll still be using ACS one way or another.
RE: Keeping weapons in deathmatch?
Posted: Thu Jun 14, 2012 3:07 pm
by Ænima
Yeah I figured i'd have to use a RESPAWN script with something like
Code: Select all
if (HasSaiga[playernumber()] ==1)
GiveInventory("Saiga",1);
... for every weapon. :/
RE: Keeping weapons in deathmatch?
Posted: Thu Jun 14, 2012 3:38 pm
by Theshooter7
Ew, you don't need 1000 arrays just for that! You can use a 2D array like so:
Code: Select all
int Equipment[32][NUM_WEAPONS_AMMO_ETC];
...
#define WEAP_SAIGA 0
...
if(Equipment[PlayerNumber()][WEAP_SAIGA] >= 1)
GiveInventory("Saiga",1);
...
etc.
For ammo and such, you can do a for loop through the ammo values of the second bracket, and just give whatever was there (assuming you are storing ammo, as giving 0 ammo doesn't give the player any ammo now does it? :V)
RE: Keeping weapons in deathmatch?
Posted: Thu Jun 14, 2012 6:35 pm
by Ænima
Oh yeahhhh. A matrix. I forgot about those.
I also tried using string arrays, but for some reason, trying to use them with CheckWeapon and SetWeapon doesn't work.
RE: Keeping weapons in deathmatch?
Posted: Thu Jun 14, 2012 7:52 pm
by Theshooter7
Ænima wrote:I also tried using string arrays, but for some reason, trying to use them with CheckWeapon and SetWeapon doesn't work.
Because that counts as dynamic string usage, I believe. Don't quote me on that, however.
RE: Keeping weapons in deathmatch?
Posted: Sat Jun 16, 2012 9:57 am
by Konda
Code: Select all
if(hasSSG) GiveInventory("SuperShotgun", 1); //I don't like this :(
There is no need for 1000 if checks. Here is a simplified version of the code above:
Code: Select all
GiveInventory("SuperShotgun", hasSSG);
In the end, you could add a 2D array (matrix) where one row has all the weapons' names and the other row has the values whether the weapon has been purchased:
Code: Select all
#define NUM_WEPS 3
int weps[2][NUM_WEPS] =
{
{"Shotgun", "SuperShotgun", "Chaingun"}, //Strings are defined as integers in ACS
{1, 0, 1}
};
script 999 RESPAWN
{
for(int i = 0; i < NUM_WEPS; i++) GiveInventory(weps[1,i], weps[2,i]);
}
See? Simple as that.
RE: Keeping weapons in deathmatch?
Posted: Mon Jun 18, 2012 12:16 pm
by Ijon Tichy
Crap shit out time goooo
Edit: Basically, what it does is, on ENTER and DEATH, it'll save the amount of weapons and ammo you have for WEAPONS and AMMO (through saveWeapons) into a 2D array specificall for storing those values, and when you respawn, it'll load those values from the 2D array and give you weapons and ammo based off the values it pulls out.
I'm not very good at explaining code in English. Look at saveWeapons and loadWeapons, that's where everything happens.
Spoiler: DA SAUCE (Open)Code: Select all
#define WEPCOUNT 8
#define AMMOCOUNT 4
#define WEPSAVE_ENTER 343
#define WEPSAVE_DEATH 344
#define WEPSAVE_RESPAWN 345
int WEAPONS[WEPCOUNT] =
{
"Chainsaw",
"Pistol",
"Shotgun",
"SuperShotgun",
"Chaingun",
"RocketLauncher",
"PlasmaRifle",
"BFG9000",
};
int AMMO[AMMOCOUNT] =
{
"Clip",
"Shell",
"RocketAmmo",
"Cell"
};
int playerWeps[32][WEPCOUNT];
int playerAmmo[32][AMMOCOUNT];
int wepOut[32];
function void saveWeapons(void)
{
int pln = PlayerNumber();
int i;
wepOut[pln] = -1;
for (i = 0; i < WEPCOUNT; i++)
{
playerWeps[pln][i] = CheckInventory(WEAPONS[i]);
if (CheckWeapon(WEAPONS[i]) )
{
wepOut[pln] = i;
}
}
for (i = 0; i < AMMOCOUNT; i++)
{
playerAmmo[pln][i] = CheckInventory(AMMO[i]);
}
}
function void loadWeapons(void)
{
int pln = PlayerNumber();
int i;
for (i = 0; i < WEPCOUNT; i++)
{
TakeInventory(WEAPONS[i], CheckInventory(WEAPONS[i]));
GiveInventory(WEAPONS[i], playerWeps[pln][i]);
}
for (i = 0; i < AMMOCOUNT; i++)
{
TakeInventory(AMMO[i], CheckInventory(AMMO[i]));
GiveInventory(AMMO[i], playerAmmo[pln][i]);
}
if (wepOut[pln] != -1)
{
SetWeapon(WEAPONS[wepOut[pln]]);
}
}
script WEPSAVE_ENTER enter
{
saveWeapons();
}
script WEPSAVE_DEATH death
{
saveWeapons();
}
script WEPSAVE_RESPAWN respawn
{
loadWeapons();
}
Completely untested, by the way. (edit: okay, cursory testing done)
Edit2: Added a little extra - it saves the weapon you're holding, if it's in WEAPONS. loadWeapons will SetWeapon to that weapon - it should be trivial to add an argument that controls that behaviour.
RE: Keeping weapons in deathmatch?
Posted: Mon Jun 18, 2012 1:03 pm
by Ænima
Wow, that's a good idea. I wouldn't have thought of doing it that way.
Mind if I test that code and possibly use it if it works?
Edit: Does Zandronum support named scripts? I know GZDoom does.
RE: Keeping weapons in deathmatch?
Posted: Mon Jun 18, 2012 1:14 pm
by Ijon Tichy
Doesn't support named scripts yet.
also do whatever the hell you want with it