Patches #666
Merge in xonotic/xonotic-data.pk3dir.git: mrbougo/weaplast_on_spawn
| Status: | Resolved | Start: | 09/18/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assigned to: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | Xonotic - 0.6 | |||
| Milestones: | ||||
| Votes: | 0 |
Description
Purpose of the branch:
The branch is mistitled. It makes weaplast fall back to the best weapon (excluding the one equipped) if the registered previous weapon is not available (e.g. in nixnex or on spawn) or has no ammo. This applies both to the laser secondary and the weaplast impulse. The second (chronological) commit removes a line that seems useless. It might need further reviewing but it looks like a nexuiz artifact rendered useless by commit cff5b8df.
Repository: xonotic/xonotic-data.pk3dir.git
Commit: e128932dd241fcc4d712a47748c0fb63d4222be5
Branch: mrbougo/weaplast_on_spawn
Merge commands:
cd data/xonotic-data.pk3dir git checkout master git reset --hard origin/master git pull && git diff 'e128932dd241fcc4d712a47748c0fb63d4222be5'..'origin/mrbougo/weaplast_on_spawn' # please check that the diff you just saw did not contain anything complex that # needs a new merge request, and review these changes git merge --no-ff 'origin/mrbougo/weaplast_on_spawn' # please make sure this merge worked, and if not, fix merge conflicts and git # commit BEFORE the next command # # also, THIS is the point to do final pre-merge testing # # use git reset --hard origin/master to bail out git push && git push --delete origin 'mrbougo/weaplast_on_spawn'
Diffstat:
qcsrc/server/cl_client.qc | 4 +--- qcsrc/server/cl_impulse.qc | 2 +- qcsrc/server/cl_weapons.qc | 9 +++++++++ qcsrc/server/w_laser.qc | 3 ++- 4 files changed, 13 insertions(+), 5 deletions(-)
Revision log:
commit e128932dd241fcc4d712a47748c0fb63d4222be5
Author: MrBougo <mrbougo@xonotic.org>
Commit: MrBougo <mrbougo@xonotic.org>
remove useless line since cff5b8df
commit c28d67f351bd2df30ec7b43e88a1031d482b50b9
Author: MrBougo <mrbougo@xonotic.org>
Commit: MrBougo <mrbougo@xonotic.org>
make weaplast and laser secondary use the best other weapon if previous is unusable
this also makes weaplast use the second best weapon on spawn
User agreed to the GPLv2+.
Diff:
1 diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc
2 index ef05663..f14a259 100644
3 --- a/qcsrc/server/cl_client.qc
4 +++ b/qcsrc/server/cl_client.qc
5 @@ -1049,8 +1049,6 @@ void PutClientInServer (void)
6 self.killcount = 0;
7 }
8
9 - self.cnt = WEP_LASER;
10 -
11 CL_SpawnWeaponentity();
12 self.alpha = default_player_alpha;
13 self.colormod = '1 1 1' * autocvar_g_player_brightness;
14 @@ -1109,7 +1107,7 @@ void PutClientInServer (void)
15 MUTATOR_CALLHOOK(PlayerSpawn);
16
17 self.switchweapon = w_getbestweapon(self);
18 - self.cnt = self.switchweapon;
19 + self.cnt = -1; // W_LastWeapon will not complain
20 self.weapon = 0;
21 self.switchingweapon = 0;
22
23 diff --git a/qcsrc/server/cl_impulse.qc b/qcsrc/server/cl_impulse.qc
24 index 939b6d2..9e211e5 100644
25 --- a/qcsrc/server/cl_impulse.qc
26 +++ b/qcsrc/server/cl_impulse.qc
27 @@ -70,7 +70,7 @@ void ImpulseCommands (void)
28 W_NextWeapon (0);
29 break;
30 case 11:
31 - W_SwitchWeapon (self.cnt); // previously used
32 + W_LastWeapon();
33 break;
34 case 12:
35 W_PreviousWeapon (0);
36 diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc
37 index fe67896..f0981f5 100644
38 --- a/qcsrc/server/cl_weapons.qc
39 +++ b/qcsrc/server/cl_weapons.qc
40 @@ -137,6 +137,15 @@ void W_PreviousWeapon(float list)
41 W_CycleWeapon(self.cvar_cl_weaponpriority, +1);
42 }
43
44 +// previously used if exists and has ammo, (second) best otherwise
45 +void W_LastWeapon()
46 +{
47 + if(client_hasweapon(self, self.cnt, TRUE, FALSE))
48 + W_SwitchWeapon(self.cnt);
49 + else
50 + W_SwitchToOtherWeapon(self);
51 +}
52 +
53 float w_getbestweapon(entity e)
54 {
55 return W_GetCycleWeapon(e, e.cvar_cl_weaponpriority, 0, -1, FALSE, TRUE);
56 diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc
57 index 5e034ac..fa52a6e 100644
58 --- a/qcsrc/server/w_laser.qc
59 +++ b/qcsrc/server/w_laser.qc
60 @@ -3,6 +3,7 @@ REGISTER_WEAPON(LASER, w_laser, 0, 1, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WE
61 #else
62 #ifdef SVQC
63 void(float imp) W_SwitchWeapon;
64 +void() W_LastWeapon;
65
66 void W_Laser_Touch (void)
67 {
68 @@ -259,7 +260,7 @@ float w_laser(float req)
69 else
70 {
71 if(self.switchweapon == WEP_LASER) // don't do this if already switching
72 - W_SwitchWeapon (self.cnt);
73 + W_LastWeapon();
74 }
75 }
76 }
History
Updated by Samual 8 months ago
- Status changed from New to Feedback
Not too sure what exactly the point of this is -- can you give example of how this would be different from old behavior?
I notice no difference while playing with it, so unsure how exactly it affects the game.
Updated by MrBougo 8 months ago
The change is most noticeable on spawn and in Nix. On spawn, the second best weapon in the inventory can be accessed using the weaplast bind or the laser secondary (you spawn with the first best, as defined in cl_weaponpriority). In Nix with laser, the player can switch between the laser and the Nix weapon using weaplast.
Previously, weaplast would tell the user that weapon X was not available if the last used weapon was somehow lost (e.g. in Nix, but also when the inventory is modified by entities I think). Now, weaplast falls back to the best or second best weapon in those cases.
Previously also, the last used weapon was set as the spawn weapon on spawn, which means that weaplast had no effect at all.
All in all, weaplast had three possible behaviors: doing nothing, complaining, or switching. Now it always does something, unless there's only one useable weapon (then it does nothing, which actually makes sense then).