After finally finding motivation to look through the game files again, I also found some of the basic class files which contain interesting stuff. They're collected in the sim-folder. There's also stuff not listed here, like Navigator and UnitCommand and Prop and Blip. I just have no clue what they do, and for modding purposes they're (probably) not that important. Moho seems to be some outside library module which I don't know, since I have little clue about Lua
#------------------
While some library seem to be used in DG, not all methods are available. String methods used in the gamefiles are:
find, format, gfind, gsub, len, lower, rep, sub, upper
#------------------
FiringRandomness: An apparently unused mechanic is that autoattacks have a chance to miss. FiringRandomness would have prevented those misses. But as far as I can see, it does nothing at the moment.
#------------------
Class relations. The respective parent classes are in parenthesis (Get it? Get it?):
Inventory()
Weapon(moho.weapon_methods)
Attacker(moho.attacker_methods)
Entity(moho.entity_methods)
Projectile(moho.prjectile_methods, Entity)
ArrowShield(Entity)
Unit(Entity)
ForgeUnit(Unit)
PowerUp(ForgeUnit)
AirUnit(ForgeUnit) - which has no properties, apparently
CharacterUnit(ForgeUnit)
HeroUnit(CharacterUnit)
MinionUnit(CharacterUnit)
StructureUnit(CharacterUnit)
FlagUnit(StructureUnit)
Shop(StructureUnit)
FactoryUnit(Shop)
SpireUnit(Shop) - Citadel it seems
RangedWeapon(Weapon)
DefaultMeleeWeapon(Weapon)
BeamWeapon(Weapon)
#------------------
Some functions you can use to return certain stats (see game files for examples with GetHealth, but not much else). All these Get-functions follow the same pattern, though:
GetEnergy = function(self)
return self.Energy or 0
end
That means although there is no GetEnergyRegen-function (for example), you can still grab that value by just accessing "unit.EnergyRegen".
Found in ForgeUnit.lua:
GetHealthPercent
SetMaxEnergy
SetEnergy
SetEnergyRegen
GetEnergy
GetMaxEnergy
GetEnergyPercent
Found in HeroUnit.lua:
GetDamageRating (Weapon/auto attack strength)
GetGold ("#Get the agent's army gold")
GetLevel
#------------------
Below are callbacks found in ForgeUnit.lua. Many buff tables use OnBuffAffect, which isn't in the list below, but also OnAbilityAdded and Regulus' Maim for example uses OnPostDamage (which let's Maim apply to Snipes and Heaven's Wrath, too). So I assume these are functional, even though I haven't tested them and ForgeUnit just defines them as "= Callback()", not sure how that works.
OnKilled
OnKilledUnit
OnCaptured
OnCapturedNewUnit
OnStartCapture
OnTransferred
OnPostDamage
OnPreDamage
OnCriticalHit
OnWeaponFire
OnTakeDamage
OnMotionHorzEventChange
OnBuffActivate
OnBuffDeactivate
OnStartBuild
OnAbilityBeginCast
OnStunned
OnFrozen
OnFinishCasting
OnAbilityAdded
OnAbilityRemoved
#------------------
Below are unit categories, which are used to select certain sets of units like for example in unit:GetAIBrain():GetCurrentUnits(categories.MINOCAPTAIN), ArmyBrains[unit:GetArmy()]:GetListOfUnits(categories.hoakspirit, false) or the more general EntityCategoryContains(categories.NOBUFFS). Haven't tested whether case matters here.
AIR
ALLUNITS
HERO
MINION
MOBILE
NOBUFFS
STRUCTURE
UNTARGETABLE
ARCHER
ARTILLERY
GIANT
PRIEST
SOLDIER
MINOCAPTAIN
HIGHPRIEST
SIEGEARCHER
hoakspirit
hqueenent
hvampirevampire01
HOculusBLightning01(/...02/...03/...04) (Found in respective ...Script.lua)
HSednaYeti (Found in HSednaYeti_Script.lua)
#------------------
On stuns being applied (see ForgeUnit.lua, BuffDefinitions.lua, BuffAffects.lua):
I tried finding out whether it is possible for Symbol of Purity being cast while stunned, and I'm not sure how it's possible.
1) When stunned, ForgeUnit.OnStunned gets called, applying the buff 'StunAbilityDisable'
2) The buff 'StunAbilityDisable' uses the function DisableAbilityUse = {Bool = true}
3) DisableAbilityUse uses the function BuffCalculate to calculate the bool values of unit.Sync.AbilitiesDisabled and unit.AbilitiesDisabled
Once unit.Sync.AbilitiesDisabled and unit.AbilitiesDisabled are set to true, it seems no ability cast can be initiated.
The function CanUseAbility (see ValidateAbility.lua) is normally used to check if you can cast (Cooldown, enough Mana, Disabled, etc.). But even if it always returns true, you cannot cast while stunned. And I tried modifying DisableAbilityUse so that instead of doing 3), it loops through a DG's current abilities and sets each individual Ability Data to Disabled, unless they have a certain value set to true (like for example CannotBeDisabled). But that also didn't work and now I'm out of ideas. I'm happy about tips.
#------------------
The entire list of global functions available in Demigod (using the function from here, thanks to TheJack for pointing it out):
ActivateMusicCue
AddAnimationEvent
AddBuildRestriction
AddTowerGraph
AddTowerNode
AddUnitFlag
ArmyCanDetect
ArmyGetHandicap
ArmyInitializePrebuiltUnits
ArmyIsCivilian
ArmyIsOutOfGame
AttachBeamEntityToEntity
AttachBeamEntityToEntityFromTable
AttachBeamToEntity
AudioSetLanguage
Basename
BeginLoggingStats
BuildUnit
CODE_PurchaseItem
CODE_SellItem
ChainTower
ChangeUnitArmy
CheatsEnabled
ClearTowerDatabase
CreateAimController
CreateAnimationState
CreateAttachedBeam
CreateAttachedEmitter
CreateAttachedEmitterTable
CreateBeamEmitter
CreateBeamEmitterOnEntity
CreateBeamEntityToEntity
CreateBeamToEntityBone
CreateCamera
CreateEmitterAtBone
CreateEmitterAtEntity
CreateEmitterOnEntity
CreateEmitterPositionVector
CreateEmitterPositionVectorTable
CreateLightParticle
CreateLightParticleIntel
CreateProfileTimer
CreateProp
CreatePropHPR
CreateReconDB
CreateSlider
CreateThreatQuery
CreateTrail
CreateUnit
CreateUnit2
CreateUnitHPR
CurrentThread
DebugGetSelectionCanDesync
DesyncLog
Dirname
DiskFindFiles
DiskFindFolders
DiskGetFileInfo
DiskToLocal
DistancePoint2Segment2
DistancePoint3Segment3
DrawCircle
DrawCircleUp
DrawLine
DrawLinePop
ElapsedMilliseconds
EndGame
EndLoggingStats
EntityCategoryContains
EntityCategoryEmpty
EntityCategoryFilterDown
EntityCategoryGetUnitList
EnumColorNames
EulerToQuaternion
FileCollapsePath
FilterEntitiesCloserThan
FilterEntitiesFurtherThan
FilterEntitiesMovingAway
FilterEntitiesNotMovingAway
FilterUnitsByArmy
FindSpotAroundCircleToOccupy
FindSpotAroundRingToOccupy
FindSpotToOccupy
FlattenMapRect
ForkThread
ForwardVector
GenerateRandomOrientation
GetAlliance
GetArmyBrain
GetArmyColor
GetArmyUnitCap
GetArmyUnitCostTotal
GetBlueprint
GetBranch
GetCurrentCommandSource
GetEntitiesInBox
GetEntitiesInCylinder
GetEntitiesInOBB
GetEntitiesInRect
GetEntitiesInSphere
GetEntitiesInSweptSphere
GetEntityById
GetFocusArmy
GetGameTick
GetGameTimeSeconds
GetGrannyAnimationResource
GetGrannyMeshResource
GetMapSize
GetMovieDuration
GetProfileTimeSeconds
GetPropsInRect
GetShields
GetSurfaceHeight
GetTerrainHeight
GetTerrainType
GetTerrainTypeOffset
GetTextureResource
GetUnitBlueprintByName
GetUnitById
GetUnitsInArea
GetUnitsInRect
GetVersion
GrannyCache
HasLocalizedVO
InitializeArmyAI
IsAlly
IsBadSpot
IsBlip
IsCollisionBeam
IsCommandDone
IsDestroyed
IsEnemy
IsEntity
IsGameOver
IsNeutral
IsProjectile
IsProp
IsRetail
IsUnit
IssueAggressiveMove
IssueAttack
IssueClearCommands
IssueClearFactoryCommands
IssueDestroySelf
IssueFactoryRallyPoint
IssueGuard
IssueKillSelf
IssueMove
IssueMoveOffFactory
IssuePatrol
IssuePause
IssueScript
IssueStop
IssueUpgrade
KillThread
LOG
LUnitMove
LUnitMoveNear
ListArmies
LuaDumpBinary
MATH_IRound
MATH_Lerp
MinLerp
MinSlerp
NotifyUpgrade
OkayToMessWithArmy
OrientFromDir
ParseEntityCategory
PointInSphere
PointVector
PurchaseSkill
PurchaseUpgrade
QRotate
Quaternion
Random
Rect
RemoveBuildRestriction
RemoveTowerGraph
RemoveTowerNode
ResumeThread
SPEW
STR_GetTokens
STR_Utf8Len
STR_Utf8SubString
STR_itox
STR_xtoi
SecondsPerTick
SelectedUnit
SetAlliance
SetAllianceOneWay
SetAlliedArmyColor
SetAlliedVictory
SetAmbientReverb
SetArmyColor
SetArmyFactionIndex
SetArmyOutOfGame
SetArmyPlans
SetArmyShowScore
SetArmyStatsSyncArmy
SetArmyUnitCap
SetAudioParameter
SetIgnoreArmyUnitCap
SetOccupyGround
SetTeamArmyName
SetTerrainType
SetTerrainTypeRect
SimConExecute
SortEntitiesByDistanceXZ
SortEntitiesByHealth
Sound
Sphere
SplitProp
StatSetFloat
StatSetInt
SubmitXMLArmyStats
SuspendCurrentThread
TestOccupy
TestRelease
TickStatAdd
TickStatAddFloat
TickStatAddInt
TickStatSetFloat
TickStatSetInt
Trace
TryCopyPose
UpdateTowerNode
VAdd
VCross
VDiff
VDist2
VDist2Sq
VDist3
VDist3Sq
VDist3XZ
VDist3XZSq
VDot
VEquals
VLength
VLengthSq
VLengthXZ
VLengthXZSq
VMult
VNormal
VPerpDot
VRotateX
VRotateY
VRotateZ
VSetMagnitude
Vector
Vector2
WARN
WaitFor
WaitTicks
Warp
_ALERT
_TRACEBACK
__pow
_c_CreateEntity
_c_CreateShield
assert
collectgarbage
dofile
error
exists
gcinfo
getfenv
getmetatable
ipairs
loadfile
loadlib
loadstring
newproxy
next
pairs
pcall
print
rawequal
rawget
rawset
require
setfenv
setmetatable
tonumber
tostring
type
unpack