The Bytecode Club

Full Version: help editing code in Net Reflector
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to modify some code in .Net Reflector for an Android game and could use some assistance as I am still learning. As you can see in the attached screenshot the sub I am trying to edit is called 'DealDamage'. I would like to make the critAttack boolean always true, AimType always to be head (0) and no damage taken. Below is the section I believe needs to be edited with my notes added.

0 ldarg.3
1 brfalse -> (5) ldarg.0
2 ldarg.0
3 ldc.i4.1
4 stfld System.Boolean Actor::critAttack
5 ldarg.0 <do I chanage this to ldarg.1 to make critAttack always True?
6 ldarg.s -> (3) aim (Actor/AimType)
7 stfld Actor/AimType Actor::attackAim
8 ldarg.2 <do I change this to ldarg.0 for always headshot? AimType is 0 = Head, 1 = Torso, 2 = Legs
9 ldnull
10 call System.Boolean UnityEngine.Object::op_Inequality(UnityEngine.Object,UnityEngine.Object)
11 brfalse -> (25) ldarg.0
12 ldarg.0
13 callvirt System.Single Actor::get_Health()
14 ldarg.1
15 conv.r4
16 sub <do I change this to add to increase health instead of decreasing?
17 ldc.r4 0
18 bgt.un -> (25) ldarg.0
19 ldarg.0
20 ldarg.2
21 stfld Weapon Actor::killedBy
22 ldarg.2
23 ldarg.0
24 callvirt System.Void Weapon::DoForcefulHitEffect(Actor)
25 ldarg.0
26 dup
27 callvirt System.Single Actor::get_health()
28 ldarg.1
29 conv.r4
30 sub
31 callvirt System.Void Actor:Worryet_Health(System.Single)
32 ldarg.1 <do I change this to idc4.1 999,999 ?
33 ldc.i4.0
34 bgt -> (146) ret
35 ldarg.2
36 ldnull
If you use dnSpy; you have to option to try, edit and recompile VB.Net or C# code as well, besides the 'manual IL code' editing that doesn't require recompilation. Judging from your screenshot, it doesn't have obfuscated class- and function-names, should the 'edit in C# or VB' should work.
But I guess you already fixed it by now Smile