![]() |
Sensing grenades in-flight
How can I get my bot to "sense" grenades (i.e. how can I get the edict of the grenade) that are thrown into its vicinity? FindEntityInSphere doesn't seem to detect them, or perhaps I'm just not using it correctly. Any tips?
-JB |
Re: Sensing grenades in-flight
Grenade entities are class-named "grenade", simply that :)
There are several ways to detect them, but this one will work: Code:
edict_t *pGrenade = NULL; |
Re: Sensing grenades in-flight
Thanks so much Pierre-Marie- you're great! Now another question...
How do grenades indicate that they've detonated? I need to be able to detect this so my bots don't think they last forever. Thanks! -JB |
Re: Sensing grenades in-flight
Well i identify grenades like this, i don't even care about detonated or not right now.
Code:
edict_t *pent = NULL; Code:
////////////////////////////////// |
Re: Sensing grenades in-flight
Think about it two_masks: if you make your bot care for grenades each frame and react accordingly, when the grenade has detonated the bot won't be able to detect it anymore since it doesn't exist anymore right ? Hence the bot won't react to it anymore...
I think you're trying to solve an unexistent problem perhaps :) |
Re: Sensing grenades in-flight
Uhm... could be me but shouldn't it check if its unequal to zero instead?
if (strcmp ("grenade", STRING (pGrenade->v.classname)) != 0) |
Re: Sensing grenades in-flight
strcmp returns zero if the strings are equal. so
Code:
if (strcmp (model_name, "models/w_hegrenade.mdl") == 0) |
Re: Sensing grenades in-flight
I was refering to PMB's post...And i find == 0 more clear then ! sometimes, dunno why 9_9
Oh and it seems that Im not the only one who had some problems the the text between the code tags... |
Re: Sensing grenades in-flight
This is because Aspirin copy and pasted the code, and when you copy-paste coloured code the formatting tags are copied as well ; plus if you enclose them between code tags, the formatting tags are disabled and then they show up...
it's a bit of a PITA I concede. Someone's gotta have a look in the PHP files again... |
Re: Sensing grenades in-flight
ok, marked the text and clicked on those 2 'A's ... so more a user fault, maybe we should just add some notes about this on the reply page ?!
|
All times are GMT +2. The time now is 23:47. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.