Raised This Month: $32 Target: $400
 8% 

Block knife attack


Post New Thread Reply   
 
Thread Tools Display Modes
Boop
Junior Member
Join Date: Dec 2006
Old 12-28-2006 , 19:17   Re: Block knife attack
Reply With Quote #11

Quote:
Originally Posted by XxAvalanchexX View Post
Either the trace isn't getting stored in the global trace handler, or I don't quite understand hull traces. Try changing the get_tr line to this:

Code:
hit = get_tr2(ptr,TR_pHit);
With this code (hit = get_tr2(ptr, TR_pHit)) , the server crash. I don't know if this will help you to find a solution : I can get an "target" if I use :

Code:
register_forward(FM_TraceHull, "fw_tracehull",1);
.... but this is not useful because I can't block the function no ?? An idea XxAvalanchexX ?
Boop is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-28-2006 , 23:58   Re: Block knife attack
Reply With Quote #12

Are you saying that if you register the forward with the 1 flag, "hit" does come up as something?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 12-29-2006 , 00:23   Re: Block knife attack
Reply With Quote #13

You usually supercede the function if you are messing with tracelines, so your previous version might work.

Thats an interesting bug there with get_tr2, not working in pre functions

[edit]
Just thought I don't think you should be using get_tr2 since this is for manually created tracelines etc.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd

Last edited by Orangutanz; 12-29-2006 at 00:26.
Orangutanz is offline
Boop
Junior Member
Join Date: Dec 2006
Old 12-29-2006 , 06:09   Re: Block knife attack
Reply With Quote #14

Quote:
Originally Posted by XxAvalanchexX View Post
Are you saying that if you register the forward with the 1 flag, "hit" does come up as something?
Yes, if I register the forward with the 1 flag, I can get ID of player who is attacked by knife. But, we can't block the function if we hook it with the flag 1 no ??
Boop is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-29-2006 , 14:21   Re: Block knife attack
Reply With Quote #15

Let's find out, use this...

Code:
new knifeImmune[33] = { true, ... }; public plugin_init() {     register_forward(FM_TraceHull,"fw_tracehull",1); } public fw_tracehull(Float:v1[3],Float:v2[3],noMonsters,hull,skipEnt,ptr); {     // not a player, or a dead one     if(!is_user_connected(skipEnt) || !is_user_alive(skipEnt))         return FMRES_IGNORED;     static hit;     hit = get_tr(TR_pHit);     // an immune player was not hit     (hit <= 0 || hit > 32 || !knifeImmune[hit])         return FMRES_IGNORED;     // override     set_tr(TR_pHit,0);     return FMRES_SUPERCEDE; }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Boop
Junior Member
Join Date: Dec 2006
Old 12-29-2006 , 16:10   Re: Block knife attack
Reply With Quote #16

Quote:
Originally Posted by XxAvalanchexX View Post
Let's find out, use this...

Code:
new knifeImmune[33] = { true, ... }; public plugin_init() { register_forward(FM_TraceHull,"fw_tracehull",1); } public fw_tracehull(Float:v1[3],Float:v2[3],noMonsters,hull,skipEnt,ptr) { // not a player, or a dead one if(!is_user_connected(skipEnt) || !is_user_alive(skipEnt)) return FMRES_IGNORED; static hit; hit = get_tr(TR_pHit); // an immune player was not hit if (hit <= 0 || hit > 32 || !knifeImmune[hit]) return FMRES_IGNORED; // override set_tr(TR_pHit,0); return FMRES_SUPERCEDE; }

This doesn't work It takes without problem "a valid hit" but the damaged are given. It doesn't block them ..... maybe because we call fw_tracehull with the flag 1 no ??

So if we use register_forward without the flag 1, we can't get the id of the player attacked with a knife. If we use register_forward with the flag 1, we can't block the attack with the knife. Is there a solution ? A bug ??
Boop is offline
Boop
Junior Member
Join Date: Dec 2006
Old 01-02-2007 , 15:02   Re: Block knife attack
Reply With Quote #17

Someone else thinks that there is a bug with trace_hull too ?
Boop is offline
Charming
BANNED
Join Date: Nov 2005
Location: Canada
Old 01-14-2007 , 11:07   Re: Block knife attack
Reply With Quote #18

trace hull is broken and i need it, fix.
Charming is offline
Send a message via ICQ to Charming Send a message via AIM to Charming Send a message via MSN to Charming Send a message via Yahoo to Charming
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-14-2007 , 17:55   Re: Block knife attack
Reply With Quote #19

Trace hull isn't broken at all.

My major oversight was ignoring how HL melee code works. First, it draws a trace line, to see if you are looking at anyone. Only if it doesn't find anyone does it do a hull check. The below code has been tested and works to prevent any knife damage.

Code:
#include <amxmodx>  #include <fakemeta>  new weapon, dummy;  public plugin_init()  {     register_forward(FM_TraceLine,"fw_traceline",1);     register_forward(FM_TraceHull,"fw_tracehull",1);  }  public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,skipEnt,ptr)  {     if(!is_user_alive(skipEnt))         return FMRES_IGNORED;     weapon = get_user_weapon(skipEnt,dummy,dummy);     if(weapon != CSW_KNIFE)         return FMRES_IGNORED;     dummy = pev(skipEnt,pev_button);     if(!(dummy & IN_ATTACK) && !(dummy & IN_ATTACK2))         return FMRES_IGNORED;     set_tr(TR_flFraction,1.0);     return FMRES_IGNORED;  }  public fw_tracehull(Float:v1[3],Float:v2[3],noMonsters,hull,skipEnt,ptr)  {     if(!is_user_alive(skipEnt))         return FMRES_IGNORED;     weapon = get_user_weapon(skipEnt,dummy,dummy);     if(weapon != CSW_KNIFE)         return FMRES_IGNORED;     set_tr(TR_flFraction,1.0);     return FMRES_IGNORED;  }

Since these are both post hooks, there is no point in returning supercede, and you can compare TR_pHit and such to make sure that the results match your conditions.

This still works as post because it is called immediately after the engine calls the trace but before it does anything with the results. So, you still have time to alter them.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 01-14-2007 at 17:58.
XxAvalanchexX is offline
lunarwolfx
Member
Join Date: Feb 2005
Old 01-15-2007 , 03:20   Re: Block knife attack
Reply With Quote #20

^wow that's amazing! Great work.
lunarwolfx 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 12:11.


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