| 77 | COMMANDN(weapon, requestweapon, "s"); |
| 78 | |
| 79 | void shiftweapon(int *s) |
| 80 | { |
| 81 | if(keypressed && player1->state == CS_ALIVE && !ispaused) |
| 82 | { |
| 83 | if(!player1->weaponsel->deselectable()) return; |
| 84 | |
| 85 | weapon *curweapon = player1->weaponsel; |
| 86 | weapon *akimbo = player1->weapons[GUN_AKIMBO]; |
| 87 | |
| 88 | // collect available weapons |
| 89 | vector<weapon *> availweapons; |
| 90 | loopi(NUMGUNS) |
| 91 | { |
| 92 | weapon *w = player1->weapons[i]; |
| 93 | if(!w) continue; |
| 94 | if(w->selectable() || w==curweapon || (w->type==GUN_PISTOL && player1->akimbo)) |
| 95 | { |
| 96 | availweapons.add(w); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // replace pistol by akimbo |
| 101 | if(player1->akimbo) |
| 102 | { |
| 103 | availweapons.removeobj(akimbo); // and remove initial akimbo |
| 104 | int pistolidx = availweapons.find(player1->weapons[GUN_PISTOL]); |
| 105 | if(pistolidx>=0) availweapons[pistolidx] = akimbo; // insert at pistols position |
| 106 | if(curweapon->type==GUN_PISTOL) curweapon = akimbo; // fix selection |
| 107 | } |
| 108 | |
| 109 | // detect the next weapon |
| 110 | int num = availweapons.length(); |
| 111 | int curidx = availweapons.find(curweapon); |
| 112 | if(!num || curidx<0) return; |
| 113 | int idx = (curidx + *s) % num; |
| 114 | if(idx<0) idx += num; |
| 115 | weapon *next = availweapons[idx]; |
| 116 | if(next->type!=player1->weaponsel->type) // different weapon |
| 117 | { |
| 118 | selectweapon(next); |
| 119 | } |
| 120 | } |
| 121 | else if(player1->isspectating()) updatefollowplayer(*s); |
| 122 | } |
| 123 | COMMAND(shiftweapon, "i"); |
| 124 | |
| 125 | void quicknadethrow(bool on) |
nothing calls this directly
no test coverage detected