Help creating Lastweap code?
Moderator: InsideQC Admins
17 posts
• Page 1 of 2 • 1, 2
Help creating Lastweap code?
Electro was helping me to create a "Lastweap" function so that I can make an alias like
alias quickaxe "impulse 0; +attack; wait; -attack; impulse 13;"
and bind a single button to attack with an axe, then switch back
to the weapon I was using (similar to quick kick in Duke3d)
It's finished..only it doesnt work.
I get a "no weapon" error every time.
So far I've added
inserted
into the W_ChangeWeapon function
added
to the impulse list
and copied the W_ChangeWeapon function
renaming it W_LastWeap
my weapons.qc can be seen in its entirety here:
http://pastebin.org/35525
Any help appreciated
alias quickaxe "impulse 0; +attack; wait; -attack; impulse 13;"
and bind a single button to attack with an axe, then switch back
to the weapon I was using (similar to quick kick in Duke3d)
It's finished..only it doesnt work.
I get a "no weapon" error every time.
So far I've added
- Code: Select all
.float lastweap;
inserted
- Code: Select all
self.lastweap = self.impulse;
into the W_ChangeWeapon function
added
- Code: Select all
if (self.impulse == 13)
W_LastWeap ();
to the impulse list
and copied the W_ChangeWeapon function
renaming it W_LastWeap
my weapons.qc can be seen in its entirety here:
http://pastebin.org/35525
Any help appreciated
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
Hmm but this isn't how I showed you to do it.
Anyway...
In W_LastWeap should actually be setting the weapon, right?
self.weapon = fl;
before
W_SetCurrentAmmo ();
I assume that when you're testing this, you haven't actually changed weapon to anything yet, so lastweap hasn't been set.
Looks like you will need to change to another weapon, then try use lastweap. Otherwise lastweap isn't set, and has no fallback, instead it's looking for fl to be 0. You have no weapon 0.
Anyway...
In W_LastWeap should actually be setting the weapon, right?
self.weapon = fl;
before
W_SetCurrentAmmo ();
I assume that when you're testing this, you haven't actually changed weapon to anything yet, so lastweap hasn't been set.
Looks like you will need to change to another weapon, then try use lastweap. Otherwise lastweap isn't set, and has no fallback, instead it's looking for fl to be 0. You have no weapon 0.
Benjamin Darling
http://www.bendarling.net/
Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
http://www.bendarling.net/
Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
- Electro
- Posts: 312
- Joined: Wed Dec 29, 2004 11:25 pm
- Location: Brisbane, Australia
I have the code you gave me as well : )
Sorry, that was pretty rude of me in retrospect.
I wanted to write what I understood (alongside the code you gave me)
I've been looking at both. At the moment they both do mostly the same thing.
The code you gave me (ill post it below so you can call me out if I left anything out) prints to screen "No Weapon" and switches to axe, but wont switch back, which i dont understand since lastweap is set at the beginning of the change weapon command.
The code i have does exactly the same thing, except it doesnt print out "No Weapon".
In testing ive been using impulse 9 cheat so i have all weapons before trying the custom impulse 13.
I wanted to write what I understood (alongside the code you gave me)
I've been looking at both. At the moment they both do mostly the same thing.
The code you gave me (ill post it below so you can call me out if I left anything out) prints to screen "No Weapon" and switches to axe, but wont switch back, which i dont understand since lastweap is set at the beginning of the change weapon command.
The code i have does exactly the same thing, except it doesnt print out "No Weapon".
In testing ive been using impulse 9 cheat so i have all weapons before trying the custom impulse 13.
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
weapons.qc
- Code: Select all
/*
============
W_ChangeWeapon
============
*/
.float lastweap;
void() W_ChangeWeapon =
{
local float it, am, fl;
it = self.items;
am = 0;
if (self.impulse == 1)
{
fl = IT_AXE;
}
else if (self.impulse == 2)
{
fl = IT_SHOTGUN;
if (self.ammo_shells < 1)
am = 1;
}
else if (self.impulse == 3)
{
fl = IT_SUPER_SHOTGUN;
if (self.ammo_shells < 2)
am = 1;
}
else if (self.impulse == 4)
{
fl = IT_NAILGUN;
if (self.ammo_nails < 1)
am = 1;
}
else if (self.impulse == 5)
{
fl = IT_SUPER_NAILGUN;
if (self.ammo_nails < 2)
am = 1;
}
else if (self.impulse == 6)
{
fl = IT_GRENADE_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
}
else if (self.impulse == 7)
{
fl = IT_ROCKET_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
}
else if (self.impulse == 8)
{
fl = IT_LIGHTNING;
if (self.ammo_cells < 1)
am = 1;
}
self.impulse = 0;
if (!(self.items & fl))
{ // don't have the weapon or the ammo
sprint (self, "no weapon.\n");
return;
}
if (am)
{ // don't have the ammo
sprint (self, "not enough ammo.\n");
return;
}
//
// set weapon, set ammo
//
self.weapon = fl;
self.lastweap = self.weapon;
W_SetCurrentAmmo ();
};
*
============
Lastweap Impulse List
Dictionary so to speak
============
*/
float() W_ImpulseForLastWeapon =
{
if (self.lastweap == IT_AXE) return 1;
else if (self.lastweap == IT_SHOTGUN) return 2;
else if (self.lastweap == IT_SUPER_SHOTGUN) return 3;
else if (self.lastweap == IT_NAILGUN) return 4;
else if (self.lastweap == IT_SUPER_NAILGUN) return 5;
else if (self.lastweap == IT_GRENADE_LAUNCHER) return 6;
else if (self.lastweap == IT_ROCKET_LAUNCHER) return 7;
else if (self.lastweap == IT_LIGHTNING) return 8;
return 1;
};
/*
============
ImpulseCommands
============
*/
void() ImpulseCommands =
{
if (self.impulse >= 1 && self.impulse <= 8)
W_ChangeWeapon ();
if (self.impulse == 9)
CheatCommand ();
if (self.impulse == 10)
CycleWeaponCommand ();
if (self.impulse == 11)
ServerflagsCommand ();
if (self.impulse == 12)
CycleWeaponReverseCommand ();
if (self.impulse == 13)
self.impulse = W_ImpulseForLastWeapon();
W_ChangeWeapon ();
if (self.impulse == 255)
QuadCheat ();
self.impulse = 0;
};
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
- Code: Select all
if (self.impulse == 13)
self.impulse = W_ImpulseForLastWeapon();
W_ChangeWeapon ();
This is bad.
that means that W_ChangeWeapon is actually ALWAYS called, not when you just do impulse 13. It needs braces.
- Code: Select all
if (self.impulse == 13)
{
self.impulse = W_ImpulseForLastWeapon();
W_ChangeWeapon ();
}
Try that and see how it goes.
Benjamin Darling
http://www.bendarling.net/
Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
http://www.bendarling.net/
Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
- Electro
- Posts: 312
- Joined: Wed Dec 29, 2004 11:25 pm
- Location: Brisbane, Australia
No weapon error gone : )
"No Weapon" error message is gone
Impulse 13 still switches directly to the axe
and does nothing the second time, even after weapon switch.
I take it that has to do with what you were saying about it checking
for fl and fl being set to 0?
But if thats the case, shouldnt it work after a weapon switch?
Impulse 13 still switches directly to the axe
and does nothing the second time, even after weapon switch.
I take it that has to do with what you were saying about it checking
for fl and fl being set to 0?
But if thats the case, shouldnt it work after a weapon switch?
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
maybe move
before
and at the top of cycleweapon and cycleweaponreverse
- Code: Select all
self.lastweap = self.weapon;
before
- Code: Select all
self.weapon = fl;
and at the top of cycleweapon and cycleweaponreverse
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
lol!
Hmm, Virgin tits or bacon :/ tough call...
- Code: Select all
if ((player.classname != "nun") || (!player.items & IT_BACON))
GTFO();
Hmm, Virgin tits or bacon :/ tough call...
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
mmmm bacon
Images removed, keep it SFW.
It is foolish to resist
It is foolish to resist
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
Please do not make the standard of this board plummet into Retardland.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
- Spirit
- Posts: 1031
- Joined: Sat Nov 20, 2004 9:00 pm
17 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
