Help! Help in HOOK!

SXYgame

Platinian
Original poster
Oct 31, 2021
40
4
8
25
加拿大蒙古
Because "Calcdamage" is shared, how to hook him so that he only works against enemies! I used Google Translate, sorry!

AND is enemy
C++:
public class CCharacter : MonoBehaviour
{

[Address(RVA = "0x3482CF0", Offset = "0x3482CF0", VA = "0x3482CF0")]
    public bool IsEnemy(CCharacter _TargetCharacter)
    {
        return default(bool);
    }
is Damage

C++:
 public static class CFormula 

[Address(RVA = "0x1275D58", Offset = "0x1275D58", VA = "0x1275D58")]
    public static void CalcDamage(CCharacterBattle _Attacker, CCharacterBattle _Defender, CDamageTemplet _DamageTemplet, float _fDamageRate, out int _nDamage, out int _nVampiric, out int _nHitRecovery)
    {
    }


Because "Calcdamage" is shared, how to hook him so that he only works against enemies! I used Google Translate, sorry!
 
Last edited:
  • Like
Reactions: 远坂凛null

Francois284Modz

Awesome Active Platinian
Jun 10, 2018
187
2,439
193
26
france
Liké isEnemy is a boom make a function pointer to that méthode and do something liké
C#:
If(isEnemy)
{
//Do something
}
 

NotALegitGuy

Solid & Active Platinian
Sep 24, 2018
69
67
18
Costa Rica
Make a function pointer to isEnemy, try looking around CCharacterBattle to see if you can find the CCharacter of it which is taken by isEnemy, if it is there then dereference it to obtain it from the _Attacker argument of CalcDamage, pass it to isEnemy and if isEnemy returns false then do whatever you want.

Example code, wrote it on the spot so might be wrong but should is still give a general idea of what i mean

C++:
bool (*IsEnemy)(std::uintptr_t _TargetCharacter);

void (*oldCalcDamage)(std::uintptr_t Instance, std::uintptr_t _Attacker, std::uintptr_t _Defender, std::uintptr_t _DamageTemplet, float _fDamageRate, int _nDamage, int _nVampiric, int _nHitRecovery);
void hkCalcDamage(std::uintptr_t Instance, std::uintptr_t _Attacker, std::uintptr_t _Defender, std::uintptr_t _DamageTemplet, float _fDamageRate, int _nDamage, int _nVampiric, int _nHitRecovery){
    if (Instance){
        // Offset is 0x0 as an example
        auto Character = *reinterpret_cast<std::uintptr_t*>((std::uint64_t)_Attacker + 0x0);
        if (!IsEnemy(Character)){
            // do whatever you want.
        }
    }
    
    return oldCalcDamage(Instance, _Attacker, _Defender, _DamageTemplet, fDamageRate, _nDamage, _nVampiric, _nHitRecovery);
}

If you can't get the Character from the CCharacterBattle then try looking another way.
 

NotALegitGuy

Solid & Active Platinian
Sep 24, 2018
69
67
18
Costa Rica
Make a function pointer to isEnemy, try looking around CCharacterBattle to see if you can find the CCharacter of it which is taken by isEnemy, if it is there then dereference it to obtain it from the _Attacker argument of CalcDamage, pass it to isEnemy and if isEnemy returns false then do whatever you want.

Example code, wrote it on the spot so might be wrong but should is still give a general idea of what i mean

C++:
bool (*IsEnemy)(std::uintptr_t _TargetCharacter);

void (*oldCalcDamage)(std::uintptr_t Instance, std::uintptr_t _Attacker, std::uintptr_t _Defender, std::uintptr_t _DamageTemplet, float _fDamageRate, int _nDamage, int _nVampiric, int _nHitRecovery);
void hkCalcDamage(std::uintptr_t Instance, std::uintptr_t _Attacker, std::uintptr_t _Defender, std::uintptr_t _DamageTemplet, float _fDamageRate, int _nDamage, int _nVampiric, int _nHitRecovery){
    if (Instance){
        // Offset is 0x0 as an example
        auto Character = *reinterpret_cast<std::uintptr_t*>((std::uint64_t)_Attacker + 0x0);
        if (!IsEnemy(Character)){
            // do whatever you want.
        }
    }
    
    return oldCalcDamage(Instance, _Attacker, _Defender, _DamageTemplet, fDamageRate, _nDamage, _nVampiric, _nHitRecovery);
}

If you can't get the Character from the CCharacterBattle then try looking another way.