Raised This Month: $ Target: $400
 0% 

forward_return and FMRES_OVERRIDE


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-22-2007 , 23:32   forward_return and FMRES_OVERRIDE
Reply With Quote #1

This is for my Weapon Immunity plugin, to make players immune to the HE grenade. The idea is to stop a grenade's FindEntityInSphere from returning any players that are immune. This is my code:

Code:
 public plugin_init()  {     register_forward(FM_FindEntityInSphere,"fw_sphere",0);  }  public fw_sphere(start,Float:origin[3],Float:radius)  {     // not a grenade's radius     if(radius != 350.0) return FMRES_IGNORED;     // run the same check to see what its result will be     new hit = engfunc(EngFunc_FindEntityInSphere,start,origin,radius);     if(is_user_alive(hit) && immune[hit][CSW_HEGRENADE])     {         // run another check to see who should be hit instead of me         hit = engfunc(EngFunc_FindEntityInSphere,hit,origin,radius);         client_print(0,print_chat,"* You got hit by a grenade! Returning instead: %i",hit);         forward_return(FMV_CELL,hit);         return FMRES_OVERRIDE;     }     return FMRES_IGNORED;  }

immune[hit][CSW_HEGRENADE] is true.

Part of this works, in that I can't take any damage from HE grenades. The message comes up and gives me a valid entity index that isn't me. The problem is that this seemingly stops any more checks from being called afterwards:

If I get a bot and turn on friendlyfire, make myself immune and him not, when I throw a grenade at us both, it tells me that I was hit by a grenade, and that it is instead returning 2 (the bot). However, the bot takes no damage (and neither do I, since I'm immune). This is the same functionality as if I were to return FMRES_SUPERCEDE.

Why wouldn't this be working?

Thanks.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 01-23-2007 , 00:26   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #2

You are printing the message to 0, everyone, so that is why it says you got hit even though you did not get hit.

But why isn't the bot getting damaged? I'm shooting in the dark, but I'm guessing the forward would be called as many times as there are players in the radius, so just ignore the one time its called for you.

Shouldn't you be able to extract the id of the player that is supposed to be hit without this line?
Code:
new hit = engfunc(EngFunc_FindEntityInSphere,start,origin,radius)
stupok is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-23-2007 , 00:45   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #3

Quote:
Originally Posted by stupok69 View Post
You are printing the message to 0, everyone, so that is why it says you got hit even though you did not get hit.
That's not even one of the problems. The message is only printed if it hits an immune player, and I'm the only immune player, so the message only appears if I get hit.

Quote:
Originally Posted by stupok69 View Post
But why isn't the bot getting damaged? I'm shooting in the dark, but I'm guessing the forward would be called as many times as there are players in the radius, so just ignore the one time its called for you.
This is how the grenade's radius damage works:
Code:
while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecSrc, flRadius )) != NULL)
I assume by "ignore" you mean to supercede it (stop it from running). In that case, it will return NULL, and the while loop will stop, thus it will stop looking for other entities. This is basically what is happening now, even though it shouldn't be.

Quote:
Originally Posted by stupok69 View Post
Shouldn't you be able to extract the id of the player that is supposed to be hit without this line?
Code:
new hit = engfunc(EngFunc_FindEntityInSphere,start,origin,radius)
If you have another method, let me know. I can't get what it will return unless it's a post hook, in which case it's too late to stop. So, I just replicate this call, the return value will be exactly the same.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 01-23-2007 , 05:43   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #4

Let's see what they'll say: http://forums.alliedmods.net/showthread.php?t=50284

EDIT: stupok69, i believe that you do not realise what's going on, though Avalanche was correct and clarified everithing for you, you have to look at his explanations.

Last edited by VEN; 01-23-2007 at 06:01.
VEN is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 01-23-2007 , 08:28   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #5

with this wrong id is no wonder,you use double find_entinsphere and save it on same variable(hit).use this and you see what i mean:
Code:
client_print(0,print_chat,"* You got hit by a grenade! Returning instead: %i",hit);         // run another check to see who should be hit instead of me hit = engfunc(EngFunc_FindEntityInSphere,hit,origin,radius);         client_print(0,print_chat,"* You got hit by a grenade! Returning instead: %i",hit);

First have your id,the second the bot id.
__________________
schnitzelmaker is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 01-23-2007 , 13:34   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #6

Though in practice it wouldn't really make much difference at least because he said that both players get "immuned". This is happen because of the issue with overriding plus here is the bug with forward_return cell/float

See the link above for details.

Last edited by VEN; 01-23-2007 at 14:00.
VEN is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 01-23-2007 , 13:38   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #7

You can use temporary to set this user in godmode during he get this damage.
__________________
schnitzelmaker is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 01-23-2007 , 14:00   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #8

My test shows, mode unset should be done at least not right after that (i.e. not in post call), pre PlayerPreThink will be fine.

And actually I do not see the problem in the parent code. He is skipping the immuned player by returning the next entity index. I believe you just didn't get the concept.

Last edited by VEN; 01-23-2007 at 14:04.
VEN is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-23-2007 , 15:58   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #9

VEN: So, the root of the problem comes down to...
Quote:
Originally Posted by sawce View Post
As for avalanche's bug, that is due to a long-standing bug with non-string forward_return values. I have it fixed locally and will commit to svn as soon as I'm done testing some other stuff.
? So I must wait for the next AMXX release? Hmm...
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 01-23-2007 , 16:18   Re: forward_return and FMRES_OVERRIDE
Reply With Quote #10

Not entirely sure how grenades work in CS, but in NS when they think, and globals->time is greater than or equal to pev->dmgtime, they blow up. You could set god mode on the players you want to be invincible, and then remove it in post.
__________________
fyren sucks
sawce is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode