Duck Survival [+3 Cheats] ad
Context
Duck Survival = Unity IL2CPP + ToLua. Ad logic lives in Lua (VipCtrl, AdManager, EventSystem).
The native tweak (DuckSpend) hooks lua_pcall / DecodeData and injects inject.lua into the live Lua state. Once lobby modules exist, we monkey-patch their globals.
How the game normally grants the reward
Typical flow:
-
UI calls
AdManager.ShowAd(reasonId, adOrPayId). -
If ad-free is set (
VipCtrl.GetAddedAdFreeFlag()), the game skips the video and firesEventDefine.OnFinishAd. -
Listeners on
OnFinishAd(shop, daily reward, etc.) grant the reward usingreasonId/adOrPayId.
So the reward is keyed off the internal Lua event OnFinishAd, not directly off the native SDK callback.
What we do (two layers)
Source: tweak/DuckSpend/inject.lua, gated by on('ads') → _G.__DuckT.ads.
1. Fake VIP / ad-free
Any code that checks “is ad-free?” before showing an ad gets true and often never reaches the SDK.
2. Short-circuit ShowAd (main reward path)
-
skip original
ShowAd→ no native video; -
immediately
Trigger(OnFinishAd, { r = reasonId, i = adOrPayId })→ same listeners as a real completion; -
optional
SendAdsEvent(3, 1)— analytics “success” (best-effort, not required for the grant).
{ r, i } matches the payload the game’s OnFinishAd handlers expect (same as the vanilla ad-free path).
Why the reward still arrives
We emulate a successful completion at the game’s Lua layer, not a fake response from the ad network. Client Lua treats the watch as done and runs its normal reward flow.
Details
| Point | Meaning |
|---|---|
|
Idempotency
|
_G.__DuckAdVip / __DuckAdShow wrap once
|
|
Toggle
|
on('ads') == false → full original path
|
|
Timing
|
wrap installs after
VipCtrl/AdManager exist in lobby (retry via pcall inject)
|
|
Server
|
if a reward is validated server-side via an ad token, this may fail; this path is client event-driven
|
Bottom line: skip = don’t call the SDK + fire OnFinishAd with the same ids, plus the VIP flag as an extra short-circuit for code that checks ad-free before ShowAd.
Create an account or sign in to comment