![]() |
UTIL_SelectItem
For the reload code, I think I can finish it off with 3 UTIL_SelectItem calls... Assuming that "primary", "secondary", and "knife" are valid calls to the SelectItem function.
Does CS provide "primary" and "secondary" as selectable weapons, or would I have to use "UTIL_SelectItem(pEdict, "weapon_usp");" followed by "UTIL_SelectItem(pEdict, "weapon_glock18");" etc. Is there a shortcut? (Please keep in mind, I am not a newb to programming, just to C++ and HL/Metamod. ;) I understand code quickly, I just need help developing my first few ideas.) |
Re: UTIL_SelectItem
Nevermind, I'm looking at the cstrike Metamod ent list... No "weapon_primary" :(
Is there an equivilant function somewhere though? One that lets me call "weapon_primary" instead of EVERY weapon, one after another, until 1 works on the current bot? |
Re: UTIL_SelectItem
Well you can simplify this, in the cBot class i keep track of what primary and secondary weapon a bot has. So i think you can do this by doing:
Code:
UTIL_SelectItem (pEdict, UTIL_GiveWeaponName (iPrimaryWeapon)); |
Re: UTIL_SelectItem
Thanks! You're assisting one of the great newb programmers! :D
|
Re: UTIL_SelectItem
Alright so what I've done is...
In bot.cpp Replaced Code:
// TODO Code:
if (FUNC_BotHasWeapon(this, UTIL_GiveWeaponName (iPrimaryWeapon)) && // we have a primary EDIT: Whoops. It doesn't compile. 9_9 Errors returned: Code:
Compiling... |
Re: UTIL_SelectItem
I think I need to put the results of "UTIL_GiveWeaponName (iPrimaryWeapon)" and "UTIL_GiveWeaponName (iSecondaryWeapon)" into variables, and call those variables in the BotHasWeapon function. I guess C++ doesn't like my function-within-a-function. 9_9
Actually, I just looked at what "UTIL_GiveWeaponName" gives, and I see that it gives the ENTITY names (weapon_knife), not the CS_WEAPON_KNIFE type names. Yay. Custom function time. Oh no... I just looked over my code and saw spaces between UTIL_GiveWeaponName and the ()'s.... Oh no... That better not have been the fix... |
Re: UTIL_SelectItem
Found my bug. Too many uses of "GiveWeaponName".
New code: Code:
if (FUNC_BotHasWeapon(this, iPrimaryWeapon) && // we have a primary |
Re: UTIL_SelectItem
looks neat, i think you can even let out BotHasWeapon and make a check it is not < 0. As iSecondaryWeapon is checked on what weapon it has....
something like: Code:
if (iSecondaryWeapon > -1 && current_Weapon.iId != iSecondaryWeapon) // we have a secondary weapon, but we do not hold it yet... |
Re: UTIL_SelectItem
*Note
i have applied your code to the 'official code'. Thanks for the contribution! :) I hope you and evy will continue this way :) |
All times are GMT +2. The time now is 18:16. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.