![]() |
![]() ![]() |
![]() |
Salvax |
![]()
Post
#1
|
![]() Advanced Member ![]() ![]() ![]() Group: Members Posts: 75 Joined: 14-February 07 Member No.: 1,034 ![]() |
bot can't hold a gravity gun even the bot profile is edited : weapon = weapon_physcannon
lost weapon code in some files of the source? ![]() i am doing some thing on checkstuck part of the codes in bot.cpp, trying if bot can use gravity gun to push the objects away, but i find bot can't even hold a gravity gun...*faint* |
Cheeseh |
![]()
Post
#2
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
bot can't hold a gravity gun even the bot profile is edited : weapon = weapon_physcannon lost weapon code in some files of the source? ![]() i am doing some thing on checkstuck part of the codes in bot.cpp, trying if bot can use gravity gun to push the objects away, but i find bot can't even hold a gravity gun...*faint* Physcannon was removed, see HLDMBot :: modthink CODE void CHLDMBot :: modThink () { // dont use physcannon for now... switch to pistol <----------------------- if ( m_pPlayerInfo->GetWeaponName() && *(m_pPlayerInfo->GetWeaponName()) ) { if ( !strcmp("weapon_physcannon",m_pPlayerInfo->GetWeaponName()) ) //<--------------------- { m_pController->SetActiveWeapon("weapon_pistol"); // <--------------------- overrides physcannon } else if ( !FStrEq(m_pProfile->getWeapon(),"default") && !FStrEq(m_pProfile->getWeapon(),m_pPlayerInfo->GetWeaponName())) { m_pController->SetActiveWeapon(m_pProfile->getWeapon()); } } } |
Salvax |
![]()
Post
#3
|
![]() Advanced Member ![]() ![]() ![]() Group: Members Posts: 75 Joined: 14-February 07 Member No.: 1,034 ![]() |
so...no matter what i do, gravity gun will be replaced ?! *faint* ...
![]() modify the code like this ? QUOTE void CHLDMBot :: modThink () { // dont use physcannon for now... switch to pistol <----------------------- if ( m_pPlayerInfo->GetWeaponName() && *(m_pPlayerInfo->GetWeaponName()) ) { if ( !FStrEq(m_pProfile->getWeapon(),"default") && !FStrEq(m_pProfile->getWeapon(),m_pPlayerInfo->GetWeaponName())) { m_pController->SetActiveWeapon(m_pProfile->getWeapon()); } } } PS:TESTed , worked !!! THX ! PS2:wait... bots won't pickup guns... ![]() ![]() ![]() PS3:finally i find out , if we have gravity gun in hands, we won't automatically switch to the gun we just picked up. *faint* |
Salvax |
![]()
Post
#4
|
![]() Advanced Member ![]() ![]() ![]() Group: Members Posts: 75 Joined: 14-February 07 Member No.: 1,034 ![]() |
now, bot can have gravity gun in hands, (deleted part of the codes as i said and set bot profile: weapon = default)
now there is a big problem, there is no defined key in in_buttons.h for PHYS_SWAP, and the PHYS_SWAP is a console command, so we can't use bot button thing but let bot use console command ![]() and i tried to do this : i thought bot wouldl switch to SMG when he is spawned in map, but in vain... ![]() ![]() ![]() - bot.cpp - QUOTE bool CBot :: createBotFromEdict(edict_t *pEdict, CBotProfile *pProfile) { char szModel[128]; init(); setEdict(pEdict); setup(); m_fTimeCreated = engine->Time(); ///////////////////////////// m_pProfile = pProfile; engine->SetFakeClientConVarValue(pEdict,"cl_team","default"); // engine->SetFakeClientConVarValue(pEdict,"cl_defaultweapon","pistol"); //salvax engine->SetFakeClientConVarValue(pEdict,"cl_autowepswitch","1"); engine->SetFakeClientConVarValue(pEdict,"phys_swap","1"); //salvax if ( m_pPlayerInfo && (pProfile->getTeam() != -1) ) m_pPlayerInfo->ChangeTeam(pProfile->getTeam()); NEED HELP , Captain ! |
Cheeseh |
![]()
Post
#5
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
you sould only hange to the gravity gun using:
--------- m_pController->SetActiveWeapon("weapon_physcannon"); ----- and change back to another weapon by using : ----- m_pController->SetActiveWeapon("weapon_pistol"); // or any other waepon name ----- I don't exactly know why you need to use "phys_swap" |
Salvax |
![]()
Post
#6
|
![]() Advanced Member ![]() ![]() ![]() Group: Members Posts: 75 Joined: 14-February 07 Member No.: 1,034 ![]() |
"phys_swap" is for switching back to a weapon the bot was holding, and SetActiveWeapon won't switch back, but only give bot a static gun.
this is the sample code for bot to push and pull objects, plz check. seems m_pController->SetActiveWeapon can't be used here directly ? - bot.cpp - QUOTE void CBot :: checkStuck () { static float fTime; fTime = engine->Time(); if ( m_fLastWaypointVisible == 0 ) { m_bFailNextMove = false; if ( !hasSomeConditions(CONDITION_SEE_WAYPOINT) ) m_fLastWaypointVisible = fTime; } else { if ( hasSomeConditions(CONDITION_SEE_WAYPOINT) ) m_fLastWaypointVisible = 0; else { if ( (m_fLastWaypointVisible + 2.0) < fTime ) { m_fLastWaypointVisible = 0; m_bFailNextMove = true; } } } if ( m_fCheckStuckTime > fTime ) return; float fVelocity = m_vVelocity.Length2D(); float fIdealSpeed = m_fIdealMoveSpeed; if ( m_pButtons->holdingButton(IN_DUCK) ) fIdealSpeed /= 2; if ( fIdealSpeed == 0 ) return; // not stuck float fPercentMoved = fVelocity/fIdealSpeed; if ( fPercentMoved < 0.1 ) { m_pButtons->jump(); m_pButtons->duck(0.25f,0.25f); m_pController->SetActiveWeapon("weapon_physcannon"); // switch to Gravity Gun by salvax , but how to make this work ? encountered error !!! m_pButtons->attack() //bot use gravity gun to push by salvax m_pButtons->attack2() //bot use gravity gun to pull by salvax m_fCheckStuckTime = fTime + 4.0f; m_pController->SetActiveWeapon(m_pProfile->getWeapon()); //switch back to the weapon in bot profile by salvax, still have error here!! } . . . . PS : how to let a bot holding a gravity gun switch to the gun he just picked up ? This problem really hurts my head ![]() PS2: how to let bot have specified weapon in bot profile and also the bot can pick up weapons ? This is very important, without this function , i can't continue. THX A LOT ! PS3: i add [void CHLDMBot :: modThink2 ()] into bot_hldm_bot.cpp for switching to gravity gun as i said above in the codes and add [modThink2 ();] into bot_hldm_bot.h under [class CHLDMBot : public CBot] if i wanna use modThink2(), what should i type? neither CHLDMBot->modThink2(); or m_pBot->modThink2(); works. ![]() |
Cheeseh |
![]()
Post
#7
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
why do you need a modthink2 ?? Just use the one function.
what error are you getting ??? anyway... CODE m_pController->SetActiveWeapon("weapon_physcannon"); // switch to Gravity Gun by salvax , but how to make this work ? encountered error !!! m_pButtons->attack() //bot use gravity gun to push by salvax m_pButtons->attack2() //bot use gravity gun to pull by salvax m_fCheckStuckTime = fTime + 4.0f; m_pController->SetActiveWeapon(m_pProfile->getWeapon()); //switch back to the weapon in bot profile by salvax, still have error here!! This won't work anyway. These sort of things only update at the end of each frame, you need to understand game programming in particular the half-life game engine. You need to SetActiveWeapon() to the weapon you want when you want it, then use it, which may take a couple of frames or a few seconds, then switch back to the weapon using m_pController->SetActiveWeapon(m_pProfile->getWeapon()); The half-life engine handles time as a consitently increasing float number, it increases by 1.0 every second. You can make a timer, by storing a variable accessabile by the bot a both start and end of the timer, such as in CBot, call it float m_flGravityGunSwitchTimer, and initialise to zero. This floating point number can be used to represent the end time you want the bot to switch back to the previous weapon by using "if (m_flGravityGunSwitchTimer && (engine->Time() > m_flGravityGunSwitchTimer))" and starting the timer by setting "m_flGravityGunSwitchTimer = engine->Time() + 2.0f;" this makes the if statement true when two seconds pass from the current time when it is given that value. This "if statement" can be checked everytime in ModThink or Think. Then after switching the weapon back to normal set "m_flGravityGunSwitchTimer = 0.0f;" The timer value can also be checked if the time is when before switching the weapons. You can find out what the previous weapon was by using "m_pPlayerInfo->GetWeaponName()" as shown in the HLDMBot::modthink code. You can store a const char* m_szPrevWeaponName, for example, and store this, and then go back to it using SetActiveWeapon on m_szPrevWeaponName. //::Init /////////// m_szPreviousWeapon = NULL; m_flGravityGunSwitchTimer = 0.0f; // changing weapon //////////// m_szPreviousWeapon = m_pPlayerInfo->GetWeaponName(); m_pController->SetActiveWeapon("weapon_physcannon"); m_flGravityGunSwitchTimer = engine->Time + 2.0f; //////////// // Think or modthink (in hldmbot) //////////// if (m_flGravityGunSwitchTimer && (engine->Time() > m_flGravityGunSwitchTimer)) // timer end { m_pController->SetActiveWeapon(m_szPreviousWeapon); m_flGravityGunSwitchTimer = 0.0f; } else if ( m_flGravityGunSwitchTimer ) // between timer { if ( RandomInt(1,100) < 10 ) PrimaryAttack(); } //////////// You can figure this kind of thing out automatically if you have experience with the engine and C++ programming. This posted code is pure example only, and may require some thinking to get it working together into the program. |
Salvax |
![]()
Post
#8
|
![]() Advanced Member ![]() ![]() ![]() Group: Members Posts: 75 Joined: 14-February 07 Member No.: 1,034 ![]() |
awesome! Thx a lot, Captain ! I would like to take some more time to explore !
hmmm, i'm gonna take exams next few days later, so...i have to focus myself on my study. I just added some simple codes: ___feb 25th 2007___ added: bot can randomly switch weapon (weapon picked up, pistol, grenade and SMG. and Be SURE in bot profile, weapon = default ). improved: bot can sprint randomly (not ONLY attacking or under attack). _____OLD LOG ______ added: bot can sprint. added: bot can have secondary attack mode (SMG Grenade, AR2 Ball, Shotgun, S.L.A.M, Grenade). You can download the latest modified source code and test only [HPB_bot2.dll] here: rcbot2_test_only_feb25.rar (test map included) http://www.sendspace.com/file/tyxlae modified_rcbot2src_base_feb25.rar http://www.sendspace.com/file/vodflz You can also search "salvax" to check the modified source code. Thank You Again, Captain Cheeseh !!! ![]() |
SuperHebbe |
![]()
Post
#9
|
Member ![]() ![]() Group: Members Posts: 23 Joined: 18-February 07 From: Norway Member No.: 1,040 ![]() |
Hi again
Can you fix so that the BOTs don't fire the ALT-weapon when they do not have ammo... Got a lot of *clicking* BOTs flying around ![]() PS! Too bad I only knows C and not C++ ![]() |
Cheeseh |
![]()
Post
#10
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
Its impossible to find out how much ammo they have, primar yor secondary ammo is impossible to retrieve through Valves plugin API, which is why I'm waiting on Valve to fix before taking this project more seriously.
|
Salvax |
![]()
Post
#11
|
![]() Advanced Member ![]() ![]() ![]() Group: Members Posts: 75 Joined: 14-February 07 Member No.: 1,034 ![]() |
life is waiting. When will Valve fix this ?!
|
![]() ![]() |
![]() |
Lo-Fi Version | Time is now: 21st August 2025 - 07:24 PM |