Title: I developped a feature "best weapon", i need help. Post by: MCMic on August 12, 2008, 01:14:33 PM 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 Quote test.tar.gz. [EDIT2] I add it in 7zip in my second post of this topic. enjoy. (please leave comments if you try it)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. 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 Code: /* I add a line in cg_local.h : Code: Line 1437 : void CG_BestWeapon_f( void ); I add a line in cg_consolecmds.c : Code: Line 469 : { "weapbest", CG_BestWeapon_f }, I add 10 lines in ui_controls2.c : Code: Line 109 : #define ID_WEAPBEST 29 So I Have that : Code: #define ID_WEAPNEXT 28 I add a line in ui_shared.c : Code: 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 : Code: /* PS : i'm french, please scuse my bad english :-/ Title: Re: I developped a feature "best weapon", i need help. Post by: sago007 on August 12, 2008, 01:55:00 PM Now I need help to add variables which allow the player to change the order of the weapons in a menu of the setup. I would add a CVAR that can look like this: cg_bestweapons "ml mg gn cg sg gl lg rl rg bfg" and then use Q_strstr to find the index of the active weapon and the weapon I just picked up (that I didn't already have or was out of ammo for) I'm not that strong in designing menues so I cannot help there. It might also change significantly in missionpack Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 12, 2008, 02:00:29 PM I wish add a variable by weapon, so the player can choose too give 0 to all weapon expect of RocketLauncher and RailGun which have 1 and 2. In this way his autoswitch/bestweaponkey will give him a RocketLauncher or nothing.
With this system the feature is more powerfull. But i don't now how add a variable, take it a default value, use it, change it, etc... (I tried but i don't understand Qvar's system) [EDIT] I add in attachment the 0.7.7 version with my modification. Title: Re: I developped a feature "best weapon", i need help. Post by: sago007 on August 12, 2008, 02:06:25 PM http://code3arena.planetquake.gamespy.com/articles/article9.shtml#placing_cvars
You can do what you say too: "rl rg" (rocket launcher < railgun) I prefer having as few CVARs as possible as they can create quite a mess with mods, that is why I would place it in one cvar. Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 12, 2008, 02:08:24 PM http://code3arena.planetquake.gamespy.com/articles/article9.shtml#placing_cvars ok, thank you, I will see that.You can do what you say too: "rl rg" (rocket launcher < railgun) I prefer having as few CVARs as possible as they can create quite a mess with mods, that is why I would place it in one cvar. Title: Re: I developped a feature "best weapon", i need help. Post by: ic3w1nd on August 13, 2008, 03:12:31 AM -first, the auto-switch siwtch only if we take a weapon better than the one we have in hand. The problem is “better” ... Well, im quite good with the rocket launcher. If we have a fight, 1:1 kicking each others ass with rockets and wooops, there is a railgun, because we wight all over the map and try to get each other, i accidently run over the item ... well, thats it, i’m dead because of the script thinks, the railgun is better :) There needs to be a function “only switch when last shot was XX seconds ago” :) Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 13, 2008, 04:46:36 AM -first, the auto-switch siwtch only if we take a weapon better than the one we have in hand. The problem is “better” ... Well, im quite good with the rocket launcher. If we have a fight, 1:1 kicking each others ass with rockets and wooops, there is a railgun, because we wight all over the map and try to get each other, i accidently run over the item ... well, thats it, i’m dead because of the script thinks, the railgun is better :) There needs to be a function “only switch when last shot was XX seconds ago” :) but first the order of weapons will can be changed in the setup, and secondly you can desable the autoswitch ;) (i don't use the auto-switch, but i use a lot the best weapon action) So I'll make a personnalisable order of weapons, and if you want add a function "only switch when last shot was XX seconds ago", do it yourself :P But what i'll maybe do is that the autoswitch only the weapon we take is better than the one we have in hand AND if we have in hand our best weapon. So if you have a rocket launcher and prefer use the shotgun, walk on a rocket launcher won't change your weapon. But for now i just try to make a personnalisable order ^^ Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 13, 2008, 05:22:59 AM http://code3arena.planetquake.gamespy.com/articles/article9.shtml#placing_cvars I tried to use only one Cvar and stock "00010203040506070809111213", for can compare the number assigned to each weapon, but i can't use "strcmp" because i can't include "string.h" : You can do what you say too: "rl rg" (rocket launcher < railgun) I prefer having as few CVARs as possible as they can create quite a mess with mods, that is why I would place it in one cvar. Code: CGAME_Q3LCC code/cgame/cg_weapons.c So can I make a table of cvars? (one by weapon) Or how can i do? Title: Re: I developped a feature "best weapon", i need help. Post by: sago007 on August 13, 2008, 07:49:00 AM Use Q_stricmp instead.
My suggestion is something like this function that returns a positive number or NULL if the weapon is not in the list. WARNING: Unverified code! Code: int weaponValue(int weaponIndex) { Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 13, 2008, 08:12:22 AM I'll first try to use a string with the values.
I have this weard error when i compile : Code: Q3ASM build/release-linux-i386/baseoa/vm/ui.qvm But "UI_WeaponsMenu" is only used in files that i didn't modified. Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 14, 2008, 10:15:09 AM I can't compile my game like you explained me in this topic http://openarena.ws/board/index.php?topic=1970.0
the folder "vm" is empty after i compile. Code: LD build/release-linux-i386/openarena.i386 The make sims work correctly. I don't understand what append. It works in the 077 repertory, but not in 080. I don't understand why. Title: Re: I developped a feature "best weapon", i need help. Post by: sago007 on August 14, 2008, 10:41:04 AM It is because I have disabled compilation of VMs.
Find "Makefile.local" open it and enable compilation of VM files again. It is disabled because most people want to compile the source to get a working binary, not to create mods. I will in the near future provide two separate tar-files. One with engine for people who need to create binaries and one with VM for people who want to mod. Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 14, 2008, 11:08:49 AM Thanks, it works, should I use a CVAR_ARCHIVE or a CVAR_USERINFO ?
Title: Re: I developped a feature "best weapon", i need help. Post by: sago007 on August 14, 2008, 11:30:26 AM Thanks, it works, should I use a CVAR_ARCHIVE or a CVAR_USERINFO ? It should be CVAR_ARCHIVE because you want to save it. It should not be a CVAR_USERINFO because it should all be done on the client side if possible. Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on August 14, 2008, 03:46:50 PM Okay, it works, I can change the order in my file q3config.cfg
Now I need to add a menu for configure that easy ^^ Title: Re: I developped a feature "best weapon", i need help. Post by: MCMic on September 09, 2008, 07:15:04 AM Hey, Where do you think I should add my menu? in "Player" ? in "Controls"? in a new category? (in controls it's the easiest, but it's not really appropriate, right?)
This menu will look like the controls menu for weapons, one line by weapon with a number to associate. |