Raised This Month: $51 Target: $400
 12% 

[TFC] Hooking functions / Medic problems.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Vancold
Member
Join Date: Jan 2015
Old 03-25-2015 , 04:02   [TFC] Hooking functions / Medic problems.
Reply With Quote #1

Hello fellows.

My question is: IS it possible for a medic to heal an opponent?
Where does the infection and healing get handled?
I actually just want to hook the function, find the healing function (original) and copypaste it so that the medic only heals everyone.

I am running an RP server so it would be really great to have the medikit working for every team.

Anyone got an idea?

PS: Anyone knows how i can disable ammo-drop after getting killed or dying?
PSS: I know it's not possible normally. But i want to recode that somehow

Last edited by Vancold; 03-25-2015 at 04:05.
Vancold is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-25-2015 , 06:16   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #2

Looking at IDA, when you hit with the medikit, it calls CTFMedikit::AxeHit().

And inside, to check whatever you can heal this player, there is just a simple function for that: CBaseEntity::IsAlly().

This function is about basically checking if current healer's team is an ally of the target's team. Technically this does that by checking against the global array teamallies[5].

Array which is filled like using value from info_tfdetect entity:
Code:
[1 (blue team)]    = "team1_allies" keyvalue
[2 (red team)]     = "team2_allies" keyvalue
[3 (yellow team)]  = "team3_allies" keyvalue
[4 (green team)]   = "team4_allies" keyvalue
I don't know exactly how works TFC and what you're doing, but I guess you could do:

- Any healers would be for example only the Green team, and you setup team4_allies to 14 (all teams), so Green team is an ally of others teams. But I'm not sure how it will affect others weapons or such. Just an idea.
- You hook CBaseEntity::IsAlly() with Okapi/Orpheu module, so you can control the return.
__________________
Arkshine is offline
Vancold
Member
Join Date: Jan 2015
Old 03-25-2015 , 07:04   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #3

Thanks for the anwser and the post. Where do i find those files that i can open with IDA that tell me such things (Directory).
Vancold is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-25-2015 , 08:30   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #4

There is no source code. IDA is a tool to disassemble/decompile a binary file (tfc.so). It helps to understand better things.
__________________
Arkshine is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 04-23-2015 , 11:15   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
Looking at IDA, when you hit with the medikit, it calls CTFMedikit::AxeHit().
How did you know which function the game called (through IDA) ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-23-2015 , 13:27   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #6

By reading what I see? lol
You should use IDA with linux binary since there are functions symbols.
__________________
Arkshine is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 04-23-2015 , 13:47   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #7

Yeah with linux binaries only, I am asking how come you know exactly that CTFMedikit::AxeHit() function is getting triggered ? Any runtime debugging or something like that ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-23-2015 , 13:49   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #8

You see it at the decompilation code.
__________________
Arkshine is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 04-23-2015 , 13:57   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #9

Still didn't get you. I opened IDA, all functions loaded, have de-compiled to .c . Now should i search the function one by one till the relevant function name (like 'Medikit AxeHit' in this case) is found ? And after guessing the function, how can you test that it is actually being called by engine ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-23-2015 , 14:35   Re: [TFC] Hooking functions / Medic problems.
Reply With Quote #10

Actually I did not try to find from where it's called.

Thread is about medikit, so all you have to do is to search a class which is similar to what you search. Here you find easily CTFMedikit in the list and you have all the relations functions:



From that, OP wants to do something when you heal, usually you would look for PrimaryAttack, but here the only function which makes sense is AxeHit. Then inside you see it uses IsAlly(), etc. I did not do more than that and I don't know from where it's called if it was your question because it's a virtual function and it's not easy to find references from that.
__________________

Last edited by Arkshine; 04-23-2015 at 14:39.
Arkshine is offline
Reply



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 11:23.


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