Dunia.dll — The Lua-Exposed API Surface
See the overview for binary identification, including the embedded Lua 4.1 (alpha)
interpreter confirmation. This page covers what C++ exposes to Lua; see Domino
Scripts for what the actual .lua script files built on top of it look like and
cover.
The interpreter is Lua 4.1, so Lua 5's library is not there (proven): a console chunk calling
ipairs fails with attempt to call global 'ipairs' (a nil value). Walk a table with a numeric
for over a count kept by hand.
Every C++ function/method exposed to the embedded Lua interpreter goes through one choke point:
RegisterLuaBinding(namespace_or_0, "Name", handlerPtr) (0x102aa850). namespace_or_0 == 0
registers a global Lua function callable from anywhere; a class-name string (e.g. "CBuddiesManager")
registers a method scoped to that manager's Lua handle, typically obtained via a GetXxxManager()
global first (several of which are themselves in the global list below, e.g. GetBuddiesManager,
GetFCXMissionManager).
The ~260 call sites (every xref to 0x102aa850) sit in ~30 distinct registration functions, each
corresponding to one exposed class or global batch. This is the authoritative map of the engine's Lua scripting surface — the source for SCRIPTS\MissionTools.lua
and friends.
Global functions (namespace = 0, callable from anywhere)
Entity/utility (0x10591120, 22 fns): GetInvalidEntityId, GetLocalPlayerId, GetEntityName,
IsEntityLoaded, IsEntityValid, AttachAnchor, ValidateSyncAnim, GetEntityInPrefab,
RemoveEntity, GetStringID, GetNoCaseStringID, PathID, SetPlayerActionMap,
PushPlayerActionMap, PopPlayerActionMap, SendForceState, DrawTextToScreen, SetVisibility,
one unnamed-string-literal binding, UnBind, GetGlobalString, GetGlobalNumber,
SpawnEntityFromArchetype.
SpawnEntityFromArchetype(name, x, y, z, ax, ay, az) (FarCry2_server 0x093c2640) spawns the
archetype named by its fully qualified hidName into the mission component's default layer, then
SetPos and SetAngles it. The three angles are degrees, the third being yaw. It returns the new
entity's id, or the invalid id when the name resolves to nothing. It does not find the ground:
the entity starts exactly at z. The id reaches Lua as a decimal string, printed %llu by the
binding (server 0x093c4550), so the invalid id reads 18446744073709551615 (proven).
Gameplay/mission scripting, batch 1 (0x109fc830, 70 fns — the single largest registration site,
almost certainly backing SCRIPTS\MissionTools.lua): SpawnPickupMissionItem, AddWeapon,
AddGadget, CameraShakeAndGamePadRumble, SpawnWeapon, RefillWeaponAmmo, RefillSyrettes,
RemoveAllWeapon, RemoveAllGadget, RemoveAllInventory, SelectWeapon, DrawWeapon,
HolsterWeapon, TeleportEntity, SpawnReinforcementScenario, SetLookAtTargetID,
PlayAnimSimpleObject, PhoneCall, CanAccessMedicine, SendAchievementData,
RemoveScriptCallback, ClearScriptCallbackID, GetMalariaPillCount, SetMalariaPillCount,
StopMalariaBlackout, SetSicknessLevel, SetBaseInfamy, EnablePostFx, DisablePostFx,
SwitchCamera, SetToScriptedCollisionGroup, SendPierceStimWithOrigin, SendPierceStimNoOrigin,
LookAtTarget, StopLookatTarget, EnableWagerRegion, DisableWagerRegion, PlayEmotion,
PopUpEndOfGame, PopUpInGameCredits, StartDefenceReversal, StopDefenceReversal,
PopUpObjective, StartBargeAssault, StopBargeAssault, BargeBreakdown, BargeRepaired,
BargeEnableZone, BargeDisableZone, StartBuddyBetrayal, BindToVehicleRide,
UnbindFromVehicleRide, StartAnimalFollowPath, StopAnimalFollowPath, SetupVehicleFollowPath,
StartVehicleFollowPath, StopVehicleFollowPath, EnableScriptedAIMode, DisableScriptedAIMode,
ForceSocialRegionToCombat, EnableRadioBroadcast, StartTownEscape, StopTownEscape,
StartDentalPlan, StopDentalPlan, StartJacksBuddy, StopJacksBuddy,
GetClosestAutomaticPrefab, SetupDefenceRevesalMikesPlace, SetupBuddyHealth, EnableCheck.
Gameplay/mission scripting, batch 2 (0x10725120, 33 fns): AddScriptedSceneParticipant,
RemoveScriptedSceneParticipant, GetFCXMissionManager, GetBuddiesManager, GetGameplayManager,
GetFCXBarkManagerService, GetWeaponBazaar, EnableTutorial, SetScriptedDeath,
StartDefoliantFX, GameChangeWorld, GameChangeWorldDefaultSpawnPoint,
GetTriggerComponentContacts, SendPlayGame, KillPawnAgent,
ChangeReinforcementRegionSpawnRate, OverrideMapTexture, GameStartStopAMBXScript,
ChangeHealingPreference, StartDesertStorm, StopDesertStorm, SetUsableEntitySize,
AddDiamonds, SetObjectiveState, AddOverrideDesertSetting, RemoveOverrideDesertSetting,
AttachAnimationPackage, DetachAnimationPackage, DeleteEntityInTrigger,
IsPartnerMissionUnlock, SendSomeoneTalkedEventToPlayer, BlockBuddyRescue,
UnblockBuddyRescue, SetCinematicUIMode.
Sound (0x10629290, 2 fns): StartSoundMixingFromLua, StopSoundMixingFromLua.
Class-scoped methods (manager singletons, obtained via a GetXxx()/instance accessor)
| Class | Method count | Methods |
|---|---|---|
CBuddiesManager | 34 | IsBuddyUnlocked, GetBuddyState, GetBuddyGender, IsBuddyAvailable, AssignBuddy, SpawnPrimaryBuddy, SpawnBuddy, GetBuddyList, GetBetrayedBuddyList, PositionSpawnedBuddy, RemoveBuddyFromWorld, MercyKilledBuddy, BetrayedBuddy, GetRescueBuddyEntityId, AddHistoryPointsToPrimaryBuddy, AddHistoryPointsToSidequestBuddy, SetSidequestMissionState, AddRescueBuddySpawnEventListener, RemoveRescueBuddySpawnEventListener, AddRescueBuddyChangedEventListener, RemoveRescueBuddyChangedEventListener, GetPrimaryBuddyName, CheatSetRescueBuddy, SetBuddyRescueActive, IsRescueBuddyAvailable, SetShowRescueBuddyInMenu, AddDefenceReversalEventListener, RemoveDefenceReversalEventListener, SetDefenceRevesalBetrayedBuddies, BypassSetPrimaryBuddy, BypassSetSecondaryBuddy, BypassSetBuddyUnlock, BypassSetBuddyHistoryPts, BypassSetBuddyLifeState |
CFCXMissionManager | 22 | ActivateBuddyMission, SelectMission, GetMissionFaction, SetCurrentMission, MissionCompleted, GiveMissionReward, WasFactionBetrayed, BypassMissionCompleted, BypassLibraryMissionOffer, BypassSetLibraryMissionState, SetLibraryMissionState, HeardBriefing, SetGreetingHeard, GetGreeting, GetAcceptedMissionCount, GetSubvertedMissionCount, SetWinningFaction, GetWinningFactionPerAct, GetWinningFaction, AddMovieSequenceToUnload, NewJackalTapeFound, PartnerTapeFound |
CDynamicEnvironmentManager | 16 | SetDepthOfFieldOverride, RemoveDepthOfFieldOverride, SetFogOverride, RemoveFogOverride, SetCloudOverride, RemoveCloudOverride, SetWindOverride, RemoveWindOverride, SetLightingOverride, RemoveLightingOverride, GetScriptedTimeOfDay, SetScriptedTimeOfDay, SetScriptedStormFactorOverride, RemoveScriptedStormFactorOverride, SetAdaptiveBloomOverride, RemoveAdaptiveBloomOverride |
CDominoManager | 10 | SpawnDominoEntity, RemoveDominoEntity, RemoveCommandEventToEntity, SendCommandEventToEntity, SendCommandEventToEntity2, QueueCommandEventToEntity, QueueCommandEventToEntity2, SendRegisteredEventToEntity, TraceConnection, IsScriptAutorunEnabled |
CGameMessageBoxHelper | 8 | CreateConfirmationMessageBox, CreateTutorialMessageBox, CreateCustomTutorialMessageBox, CreateFloatingTutorialMessageBox, CreateTutorialMessageBoxWithActionMap, CreateCustomTutorialMessageBoxWithActionMap, CreateFloatingTutorialMessageBoxWithActionMap, HideFloatingTutorialMessageBox |
CScriptCallbackSystem | 8 | RegisterEventCallback, RegisterOnSpawnCallback, RegisterOnRemoveCallback, RemoveCallback, RemoveCallbacks, RegisterMessageListener, UnregisterMessageListener, BroadcastMessage |
CFCXBarkManagerService | 4 | LoadMissionBarkBank, UnloadMissionBarkBank, RegisterMissionBankLoadedCallback, UnregisterMissionBankLoadedCallback |
CBaseMission | 5 | IsEnabled, one unnamed-string-literal binding, Enable, Disable, SetState |
CDominoDelayManager | 4 | CreateDelay, RemoveDelay, SetDelay, SendCommand |
CDominoConsoleCommandManager | 2 | RegisterConsoleCommand, UnregisterConsoleCommand |
CDominoSequenceManager | 2 | CreateListener, DeleteListener |
CDominoBoxResource | 2 | RegisterBox, LoadResource |
CDominoBoxInstance | 2 | CreateBox, GetParentEntity |
CMusicManager | 3 | SetWorld, ChangeSet, PlayMusicFromLua |
CDominoSoundManager | 1 | PlaySound |
CMovieSystem | 1 | CommandSequence |
CGameMissionMgr | 1 | GetMission |
CFCXRegionManager | 1 | IsSafeHouseLocked |
CFCXObjectiveHudManager | 1 | PushNewObjective |
CDominoWaterLevelManager | 1 | SetWaterLevel |
CTerrain | 1 | GetSector |
CSector | 1 | SetWaterLevel |
CEntityComponent | 1 | GetEntity |
CVehicle | 1 | GetCurrentVehicle |
CFCXGameplayManager | 1 | SetMapArmy |
CJackalTapeManager | 1 | StopTape |
Each of these manager classes also exposes a much larger set of plain data properties (not
functions) through a separate, parallel reflection mechanism (FUN_1029b000/property-descriptor
structs with GetNameHash("PropertyName", ...), visible interleaved in the same registration
functions — e.g. CFCXMissionManager also exposes CurrentAct, MissionTime,
InfMinCoefficient, etc. as readable/writable fields). Those are not listed here, but are readable
from the same decompiled registration functions.
Writing Lua for the engine
What the embedded Lua 4.1 (alpha) means for a script, all met while writing a scripted knockdown (seen in game):
- There are no booleans.
trueandfalseare ordinary global names, so both arenil;truepassed to a function arrives asnil. Onlynilis false:0is true. A function that has to choose between two behaviours is clearer as two functions. - There is no
pcall. The engine runs Domino callbacks in its own protected call, so an error in one is reported and the game goes on. - Bindings check the type.
SetScriptedDeath(0x088A5210) acts only when given exactly one argument whoselua_tagis a number, soSetScriptedDeath(1)works andSetScriptedDeath(true)does nothing. - A callback object needs a
_type. The engine calls back into a table passed toRegisterEventCallbackorCDominoDelayManager:CreateDelayas Domino boxes are built, through the table's_type. A plain table must point_typeat itself (T._type = T); without it the callback fails with "attempt to index a nil value" and the game exits (seen on GOG atDunia.dll+0x2BE795).
Unknowns
- One registration call site (
0x10738c38) sits outside any function Ghidra has identified as aFunctionobject — needs a manual Disassemble+Create-Function pass in the GUI before it's readable via MCP. Every other one of the ~260 sites is covered above.