Hi, I developped my own feature, who allow two things:
-first, the auto-switch siwtch only if we take a weapon better than the one we have in hand.
-The second thing is the possibility to assign to a key the action "choose the best weapon I have" (I choose the right click)
The order of weapons is the default order (so the best weapon is the plasma gun, but if we talk about damage/second, it is really the best weapon)
Now I need help to add variables which allow the player to change the order of the weapons in a menu of the setup.
If you want to test, there is a version of OA 0.7.7 with my feature in attachment.
[EDIT] it doesn't works, it said
test.tar.gz.
You cannot upload that type of file. The only allowed extensions are txt,doc,pdf,jpg,gif,mpg,png,md3,blend,c,h,shader,script,skin,tga,wav,ogg,mp3,map,zip,tar.gz,bz2,tar.bz2,7z.
[EDIT2] I add it in 7zip in my second post of this topic. enjoy. (please leave comments if you try it)
My modification of the code :
I add a function CG_BestWeapon_f() in the file cgame/cg_weapon.c, just after the function CG_NextWeapon_f
/*
===============
CG_BestWeapon_f
===============
*/
void CG_BestWeapon_f( void ) {
int i;
int original;
if ( !cg.snap ) {
return;
}
if ( cg.snap->ps.pm_flags & PMF_FOLLOW ) {
return;
}
cg.weaponSelectTime = cg.time;
original = cg.weaponSelect;
for ( cg.weaponSelect = 0 ; cg.weaponSelect < MAX_WEAPONS ; cg.weaponSelect++ ) {
if ( CG_WeaponSelectable( cg.weaponSelect ) && cg.weaponSelect > original) {
original = cg.weaponSelect;
}
}
if ( i == MAX_WEAPONS ) {
cg.weaponSelect = original;
}
}
I add a line in cg_local.h :
Line 1437 : void CG_BestWeapon_f( void );
I add a line in cg_consolecmds.c :
Line 469 : { "weapbest", CG_BestWeapon_f },
I add 10 lines in ui_controls2.c :
Line 109 : #define ID_WEAPBEST 29
Line 189 : menuaction_s bestweapon;
Line 261 : {"weapbest", "best weapon", ID_WEAPBEST, ANIM_IDLE, '0', -1, -1, -1},
Line 303 : (menucommon_s *)&s_controls.bestweapon,
Line 1420-1424 : s_controls.bestweapon.generic.type = MTYPE_ACTION;
s_controls.bestweapon.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.bestweapon.generic.callback = Controls_ActionEvent;
s_controls.bestweapon.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.bestweapon.generic.id = ID_WEAPBEST;
Line 1612 : Menu_AddItem( &s_controls.menu, &s_controls.bestweapon );
For the Define, i add 1 to all the define for can insert mine.
So I Have that :
#define ID_WEAPNEXT 28
#define ID_WEAPBEST 29
#define ID_GESTURE 30
#define ID_CHAT 31
#define ID_CHAT2 32
#define ID_CHAT3 33
#define ID_CHAT4 34
// all others
#define ID_FREELOOK 35
#define ID_INVERTMOUSE 36
#define ID_ALWAYSRUN 37
#define ID_AUTOSWITCH 38
#define ID_MOUSESPEED 39
#define ID_JOYENABLE 40
#define ID_JOYTHRESHOLD 41
#define ID_SMOOTHMOUSE 42
...
I add a line in ui_shared.c :
Line 3165 : {"weapbest", '°', -1, -1, -1},
I think it's all for the second thing.
for the first, i just changed the function CG_ItemPickup in cg_event :
/*
================
CG_ItemPickup
A new item was picked up this frame
================
*/
static void CG_ItemPickup( int itemNum ) {
cg.itemPickup = itemNum;
cg.itemPickupTime = cg.time;
cg.itemPickupBlendTime = cg.time;
// see if it should be the grabbed weapon
if ( bg_itemlist[itemNum].giType == IT_WEAPON ) {
// select it immediately
if ( cg_autoswitch.integer && bg_itemlist[itemNum].giTag != WP_MACHINEGUN && bg_itemlist[itemNum].giTag > cg.weaponSelect ) {
cg.weaponSelectTime = cg.time;
cg.weaponSelect = bg_itemlist[itemNum].giTag;
}
}
}
PS : i'm french, please scuse my bad english :-/