應用名:最強塔防
包名:com.smgstudio.otttd
一個朋友說很喜歡這個游戲的Endless模式,之前的下載的破解版并不能滿足要求,難度還是很大,基地的血量也很薄,希望調(diào)整一下。于是乎幫忙弄下。先來一張游戲截圖(左側(cè)的雙英雄已陣亡。。。)。

反編譯apk,瀏覽下各個目錄,習慣性的看下asset,找到了Assembly-CSharp.dll。丟到工具中,發(fā)現(xiàn)居然未加密。。。那么剩下的就只有找到代碼然后修改了。
先大體瀏覽下,類名都很規(guī)范,也沒有混淆之類的,更方便我們查找。既然是修改血量相關(guān)的,嘗試搜health之類的關(guān)鍵詞。


從結(jié)果上看,GE_BaseUnit的比較可疑,先跟進看看getHealth()方法

查看一下_health,給的是100f
protected float _health = 100f;
還有一個getHealthP(),看方法是計算百分比的,這樣的話就不好改成幾百萬血之類的。繼續(xù)瀏覽GE_BaseUnit類,看看其他函數(shù)情況。往下走,看到一個dealDamage()函數(shù),處理傷害值的。于是想到可以將敵方的傷害降低到0,這樣變相的相當于基地無敵。。。

來看代碼
// GE_BaseUnit
// Token: 0x060006BA RID: 1722 RVA: 0x0002387C File Offset: 0x00021A7C
public virtual void dealDamage(float dmg, GE_GameConst.dmgType dType, GE_BaseUnit inSourceUnit)
{
if (this._isDead)
{
return;
}
if (this._hasAffectors)
{
this.i = this._unitAffectorKeys.Count - 1;
while (this.i >= 0)
{
if (this._unitAffectors.ContainsKey(this._unitAffectorKeys[this.i]))
{
GE_BaseUnitAffector ge_BaseUnitAffector = this._unitAffectors[this._unitAffectorKeys[this.i]];
dmg = ge_BaseUnitAffector.interceptDMG(dmg, dType, inSourceUnit);
}
else
{
this._unitAffectorKeys.Remove(this._unitAffectorKeys[this.i]);
Debug.LogWarning("affector keys out of sync with dictionary");
}
this.i--;
}
}
switch (dType)
{
case GE_GameConst.dmgType.physical:
dmg *= this.phys_dmg_multiplyer;
break;
case GE_GameConst.dmgType.energy:
dmg *= this.energy_dmg_multiplyer;
break;
case GE_GameConst.dmgType.fire:
dmg *= this.fire_dmg_multiplyer;
break;
}
this.dmgDisplay = 2f;
if (!this._isCurrentlyUsingHitStateMaterials && this._hasHitStateMaterials && !this._isCurrentlyUsingHitStateMaterials)
{
this.updateMaterials(true);
this._isCurrentlyUsingHitStateMaterials = true;
}
this._health -= dmg;
if (this._health <= 0f)
{
this._health = 0f;
this.killUnit(inSourceUnit);
}
}
通過觀察參數(shù),我們得知這是一個通用的處理傷害值的函數(shù),因為需要傳進來float的傷害值,dmgType傷害值類型,inSourceUnit類型。
public enum unitType
{
// Token: 0x040000B7 RID: 183
tower,
// Token: 0x040000B8 RID: 184
hero,
// Token: 0x040000B9 RID: 185
enemy,
// Token: 0x040000BA RID: 186
hq
}
public enum dmgType
{
// Token: 0x040000BC RID: 188
physical,
// Token: 0x040000BD RID: 189
energy,
// Token: 0x040000BE RID: 190
fire,
// Token: 0x040000BF RID: 191
special
}
this._health -= dmg處理血量值的減少。
快速試驗下,把這行改掉,讓HP不變:
this._health -= dmg; -----> this._health -= 0;
打包apk驗證,果然無論是敵人的血量還是自己的血量都不再減少了,雙方互相秀恩愛。
前面我們判斷過了這是一個通用的處理傷害值的函數(shù),所以找找哪些地方調(diào)用了dealDamage。

好了,這下一目了然了,函數(shù)名都很清楚的標明是哪個目標。比如大本營是HQ,英雄是BaseHero等等。分別跟進去,在調(diào)用dealDamage之前將dmg置為0就行了,這樣相當于傳進去的傷害值為0,在執(zhí)行this._health -= dmg的時候,HP是不會減少的。例如大本營GE_HeroCropHQ的改法。

打包重新驗證,己方的都是無敵的了,這還算什么塔防??。。。
apk和資源包連接:
鏈接: https://pan.baidu.com/s/1c1P2HYo 密碼: dwr5
使用方法:
1、安裝apk
2、將com.smgstudio.otttd文件夾拷貝到/sdcard/Android/obb/目錄
3、聯(lián)網(wǎng)打開游戲,開玩兒