This is the AMP version of this page.
If you want to load the real page instead, click this text.

Help! Hooking VOID multiplier function

DeeNastyle

Platinian
Hi guys,

I took my first steps at modding a few days ago but I can't manage to make my function work.
I'm using LGL Model Menu template 3.2 to mod a unity libil2cpp game on android.

I want to do a damage multiplier function with a slider.
Here the offset I've found with dnSpy:




On Main.cpp I've tried the following:













Any clue how to make the function work ?

Thanks guys,
 

Attachments

  • 1659130517153.png
    4.9 KB · Views: 68
  • 1659130578286.png
    90.4 KB · Views: 80
Last edited:
C++:
if (instance && DamageMultiplier > 1) {
    hpDamage *= DamageMultiplier;
    shieldDamage *= DamageMultiplier;
}

It must be so, you haven't provided all the necessary arguments to the ApplyAttackDamage method yet.

In the switch construction, value has an integer type, which means that it would be more correct to specify the type not float (real) but int (integer), It's certainly not a bug, but still.
 
It's an online game yes but battle calculation are client-sided, there is a lot of working mod menu out there with damage multiplier & defence multiplier functions..just trying to make my own :)

I will try to change the switch construction, thank you guys.
 
try this
C++:
float DamageMultiplier;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule){
     if (instance != NULL && DamageMultiplier > 1){
          return old_ApplyAttackDamage(instance,int hpDamage * DamageMultiplier ,int shieldDamage * DamageMultiplier,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
     }
     return old_ApplyAttackDamage(instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
}

HOOK("OFFSETS",ApplyAttackDamage,old_ApplyAttackDamage);


switch(featNum):
case 10:
          if (value >= 1){
               DamageMultiplier = value;
          }
break;
 
Thank you for the answers.


I can't even build LGL Mod Menu with this code, it does not understand "BattleUnitController", "attacker", "UnitMoveType", "moveType" etc.
"BattleUnitController" and so on are lib classes
"attacker" and so on are lib parameters


It didn't worked neither but I guess it also about void calling..

So I've tryied the following:

C++:
int DamageMultiplier = 1;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* BattleUnitController,void* UnitMoveType,void* DamageTypeEnum,bool showUiMessaging,bool canCounterAttack,void* BattleEffectDO,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* BattleUnitController,void* UnitMoveType,void* DamageTypeEnum,bool showUiMessaging,bool canCounterAttack,void* BattleEffectDO,bool fromDestroyModule)
 {
    if (instance != NULL && DamageMultiplier > 1)
    {
        return old_ApplyAttackDamage(instance, hpDamage * DamageMultiplier , shieldDamage * DamageMultiplier, isCrit, BattleUnitController, UnitMoveType, DamageTypeEnum, showUiMessaging, canCounterAttack, BattleEffectDO, fromDestroyModule);
    }
    return old_ApplyAttackDamage(instance, hpDamage, shieldDamage, isCrit, BattleUnitController, UnitMoveType, DamageTypeEnum, showUiMessaging, canCounterAttack, BattleEffectDO, fromDestroyModule);

 }

HOOK("0xd92288", ApplyAttackDamage, old_ApplyAttackDamage);

    switch (featNum) {
        
        case 11:
            if (value >= 1) {
                DamageMultiplier = value;
            }
            break;

I can build the Mod Menu and recompile the apk with this one but it's not working, any other clue ?
 
you need to make a function pointer
 

this is not recommended
 
yea i mean , its work for me because most of my mod was have somethink like that in the dump , so yea need to cast all the think into hook variable
 
try this , this is was improved version
C++:
float DamageMultiplier;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* attacker,void* target,void* moveType,int damageType,bool showUiMessaging,bool canCounterAttack,[Optional] void* sourceEffect,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* attacker,void* target,void* moveType,int damageType,bool showUiMessaging,bool canCounterAttack,[Optional] void* sourceEffect,bool fromDestroyModule){
     if (instance != NULL && DamageMultiplier > 1){
          return old_ApplyAttackDamage(instance,int hpDamage * DamageMultiplier ,int shieldDamage * DamageMultiplier,isCrit,attacker,target,damageType,showUiMessaging,canCounterAttack,[Optional] sourceEffect,fromDestroyModule);
     }
     return old_ApplyAttackDamage(instance,hpDamage,shieldDamage,isCrit,attacker,target,moveType,damageType,showUiMessaging,canCounterAttack,[Optional] sourceEffect,fromDestroyModule);
}

HOOK("OFFSETS",ApplyAttackDamage,old_ApplyAttackDamage);


switch(featNum):
case 10:
          if (value >= 1){
               DamageMultiplier = value;
          }
break;
[/QUOTE]
 
[/QUOTE]
this is not recommended, why should type void return? and consuming too much space should be easy, just replace the parameter with a damagemultiplier.