AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   forward_return and FMRES_OVERRIDE (https://forums.alliedmods.net/showthread.php?t=50275)

XxAvalanchexX 01-22-2007 23:32

forward_return and FMRES_OVERRIDE
 
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.

stupok 01-23-2007 00:26

Re: forward_return and FMRES_OVERRIDE
 
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)

XxAvalanchexX 01-23-2007 00:45

Re: forward_return and FMRES_OVERRIDE
 
Quote:

Originally Posted by stupok69 (Post 430518)
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 (Post 430518)
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 (Post 430518)
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.

VEN 01-23-2007 05:43

Re: forward_return and FMRES_OVERRIDE
 
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.

schnitzelmaker 01-23-2007 08:28

Re: forward_return and FMRES_OVERRIDE
 
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.

VEN 01-23-2007 13:34

Re: forward_return and FMRES_OVERRIDE
 
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.

schnitzelmaker 01-23-2007 13:38

Re: forward_return and FMRES_OVERRIDE
 
You can use temporary to set this user in godmode during he get this damage.

VEN 01-23-2007 14:00

Re: forward_return and FMRES_OVERRIDE
 
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.

XxAvalanchexX 01-23-2007 15:58

Re: forward_return and FMRES_OVERRIDE
 
VEN: So, the root of the problem comes down to...
Quote:

Originally Posted by sawce (Post 430571)
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...

sawce 01-23-2007 16:18

Re: forward_return and FMRES_OVERRIDE
 
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.


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

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