Содержание:

Справочник по скриптовому API HoMM V, версия 1.3

1. Про всякое.
2. Немножко про LUA.
3. Реализация скрипт-системы в HoMMV.
  • 3.1. Функции, доступные везде.
1. number sqrt( number )
2. number mod( number1, number2 )
3. number random( nHi )
4. void sleep( nSegments )
5. fProc parse( sToEval )
6. void print( s1, s2, ... )
7. void print_to( sFileName, v1, string2, ... )
8. sFileName create_file( sFileName )
9. sFileName open_file( sFileName )
10. void _ERRORMESSAGE( sMsg )
11. void errorHook( fCallback )
12. void startThread( fProc, vParam1, vParam2, ... )
13. void doFile( spFileLUA )
14. nDifficulty GetDifficulty()
15. void consoleCmd( sCmd )
16. void SetGameVar( sVarName, sValue )
17. string GetGameVar( sVarName )
18. void Save( sSaveName )
19. void Load( sSaveName )
20. void TutorialSetBlink( sID, nOn )
21. void TutorialMessageBox( sID )
22. bool IsTutorialMessageBoxOpen()
23. bool IsTutorialItemEnabled( sID )
24. void TutorialActivateHint( sID )
25. void TutorialSetBlink( sID, nBlink )
  • 3.2. Стратегический режим.
3.2.1 Общая работа с параметрами игрока.
26. nPlayerID GetCurrentPlayer()
27. nPlayerStateID GetPlayerState( nPlayerID )
28. number GetPlayerResource( nPlayerID, nResID )
29. void SetPlayerResource( nPlayerID, nResID, nCount )
30. void SetPlayerStartResources( nPlayerID, nWoodCnt, nOreCnt, nMercuryCnt, nCrystalCnt, nSulfurCnt, nGemCnt, nGoldCnt )
31. tsHeroes GetPlayerHeroes( nPlayerID )
32. void SetPlayerHeroesCountNotForHire( nPlayerID, nCount )
33. nPlayerID GetObjectOwner( sObjectName )
34. void SetObjectOwner( sObjectName, nPlayerID )
35. bool IsObjectVisible( nPlayerID, sObjectName )
36. void OpenCircleFog( nX, nY, nFloorID, nRadius, nPlayerID )
3.2.2 Работа с объективами (или с обжективами – кому как).
37. nState GetObjectiveState( sObjectiveName, nPlayerID = PLAYER_1 )
38. void SetObjectiveState( sObjectiveName, nState, nPlayerID = PLAYER_1 )
39. nProgress GetObjectiveProgress( sObjectiveName, nPlayerID = PLAYER_1 )
40. void SetObjectiveProgress( sObjectiveName, nProgress, nPlayerID = PLAYER_1 )
41. bool IsObjectiveVisible( sObjectiveName, nPlayerID = PLAYER_1 ) 17
42. void SetObjectiveVisible( sObjectiveName, bVisible, nPlayerID = PLAYER_1 )
3.2.3 Работа с ключами.
43. bool HasBorderguardKey( nPlayerID, nKeyID )
44. void GiveBorderguardKey( nPlayerID, nKeyID )
3.2.4 Работа с регионами.
45. void SetRegionBlocked( sRegionName, bEnable, nPlayerID = -1 )
46. bool IsRegionBlocked( sRegionName, nPlayerID )
47. tsObjects GetObjectsInRegion( sRegionName, nObjectsTypeID )
48. nX, nY, nFloorID RegionToPoint( sRegionName )
49. bool IsObjectInRegion( sHeroName, sRegionName )
50. void OpenRegionFog( nPlayerID, sRegionName )
3.2.5 Работа с AI.
51. void SetAIPlayerAttractor( sObjectName, nPlayerID, nPriority )
52. void SetAIHeroAttractor( sObjectName, sHeroName, nPriority )
53. void EnableHeroAI( sHeroName, bEnable )
54. void MoveHero( sHeroName, nX, nY, nFloorID = -1 )
55. bool CanMoveHero( sHeroName, nX, nY, nFloorID = -1 )
56. void EnableAIHeroHiring( nPlayerID, sTownName, bEnable )
3.2.6 Работа с героями.
57. nCount GetHeroStats(HeroName, nStatID)
58. void ChangeHeroStat( sHeroName, nStatID, nDelta )
59. bool HasHeroSkill( sHeroName, nSkillID )
60. bool GiveHeroSkill( sHeroName, nSkillID )
61. void KnowHeroSpell( sHeroName, nSpellID )
62. void TeachHeroSpell( sHeroName, nSpellID )
63. bool LevelUpHero( sHeroName )
64. nLevel GetHeroLevel( sHeroName )
65. bool IsHeroAlive( sHeroName )
66. void DeployReserveHero( sHeroName, nX, nY, nFloorID = GROUND )
67. void UnreserveHero( sHeroName )
68. nCost CalcHeroMoveCost( sHeroName, nX, nY, nFloorID = -1 )
69. void MoveHeroRealTime( sHeroName, nX, nY, nFloorID = -1 )
70. nCount GetHeroCreatures( sHeroName, nCreatureID )
71. void AddHeroCreatures( sHeroName, nCreateureID, nCount )
72. void RemoveHeroCreatures( sHeroName, nCreatureID, nCount )
73. void GiveArtefact( sHeroName, nArtID, nBindToHero = 0 )
74. bool HasArtefact(sHeroName, nArtID)
75. void RemoveArtefact( sHeroName, nArtID )
76. void SetHeroLootable( sHeroName, bEnable )
77. bool IsHeroLootable( sHeroName )
78. void MarkObjectAsVisited( sObjectName, sHeroName )
79. sTownName GetHeroTown( sHeroName )
80. sHeroName GetTownHero( sTownName )
81. tsObjects GetObjectsFromPath( sHeroName, nX, nY, nFloorID = -1 )
82. void GiveHeroWarMachine( sHeroName, nWarMachineID )
83. void HasHeroWarMachine( sHeroName, nWarMachineID )
84. bool RemoveHeroWarMachine( sHeroName, nWarMachineID )
85. void StartCombat( sHeroName, sEnemyHeroName, nEnemyIDCount, nCreatureID1, nCount1, nCreatureID2, nCount2, ..., spScriptXDB, sFinishProc, spAdventureFlybySceneXDB = nil )
86. void SetHeroCombatScript( sHeroName, spScriptXDB )
87. void ResetHeroCombatScript( sHeroName )
88. void SiegeTown( sHeroName, spAdvMapTownXDB, spAdventureFlybySceneXDB = nil )
3.2.6 Работа с городами.
89. nLevel GetTownBuildingLevel( sTownName, nBuildingID )
90. nLevel GetTownBuildingLimitLevel( sTownName, nBuildingID )
91. nLevel GetTownBuildingMaxLevel( sTownName, nBuildingID )
92. void SetTownBuildingLimitLevel( sTownName, nBuildingID, nLevel )
93. void TransformTown( sTownName, nTownTypeID )
94. void RazeTown( sTownName )
3.2.7 Работа с объектами.
95. nX, nY, nFloorID GetObjectPosition( sObjectName )
96. void SetObjectPosition( sObjectName, nX, nY, nFloorID = -1 )
97. void RemoveObject( sObjectName )
98. bool IsObjectExists( sObjectName )
99. bool IsObjectEnabled( sObjectName )
100. void SetObjectEnabled( sObjectName, bEnable )
101. tsObjects GetObjectNamesByType( sObjectTypeSubstr )
102. void AddObjectCreatures( sObjectName, nGreatureID, nCount )
103. nCount GetObjectCreatures( sObjectName, nCreatureID )
104. void RemoveObjectCreatures( sObjectName, nCreatureID, nCount )
105. void SetObjectDwellingCreatures( sObjectName, nCreatureID, nCount )
106. nCount GetObjectDwellingCreatures( sTownName, nCreatureID )
107. void CreateArtifact( sArtName, nArtID, nX, nY, nFloorID )
108. void ShowFlyingSign( spTXT, sObjectName, nPlayerID = -1, nTimeSec = 1.0)
109. void CreateMonster( sMonsterName, nCreatureID, nCount, nX, nY, nFloorID, nMonsterMoodID, nCreatureCourageID )
110. void RemoveAllMonsters( nCreatureID )
111. void GenerateMonsters( nCreatureID, nCountGroupsMin, nCountGroupsMax, nCountInGroupMin, nCountInGroupMax )
3.2.8 Работа с интерфейсом.
112. void QuestionBox( spTXT, sCallback )
113. void StartDialogScene( spDialogSceneXDB, sCallback = nil, sSaveName = nil )
114. void StartCutScene( sAnimSceneXDB, sCallback = nil, saveName = nil )
115. void MessageBox( spTXT, sCallback = nil, sSaveName = nil )
116. void StartDialogSceneInt( spDialogSceneXDB, sCallback, sSaveName )
117. void StartCutSceneInt( spAnimSceneXDB, sCallback, sSaveName )
118. void MessageBoxInt(spTXT, sCallback, sSaveName)
119. void MoveCamera( nX, nY, nFloorID, nZoom = 50, nPitch = pi/2, nYawl = 0, nNoZoom = 0, nNoRotate = 0 )
3.2.9 Функции общей направленности.
120. void Loose()
121. void Win()
122. void BlockGame()
123. void UnblockGame()
124. void ExitGame()
125. number GetDate( nDateID )
126. nX, nY GetTerrainSize()
127. number GetMaxFloor()
128. bool IsTilePassable( nX, nY, nFloorID = GROUND )
129. string GetAllNames( nFilterCode )
130. void SetWarfogBehaviour( nOnLand, nOnSea )
131. void Trigger(nTriggerType, ...)
3.2.10 Работа со звуком.
132. nSoundID Play3DSound( spSoundXDB, nX, nY, nFloorID )
133. nSoundID Play2DSound( spSoundXDB )
134. void StopPlaySound( nSoundID )
3.2.11 Работа с освещением.
135. void SetCombatAmbientLight( spAmbientLightXDB )
136. void SetObjectFlashlight( sObjectName, sLightID )
137. void SetAmbientLight( nFloorID, sLightID, bFade = false, nTime = 1)
3.2.12 Всякие непонятки.
138. number CalcAverageMonstersTier()
139. tnTier GetGuardsTier( sObjectName )
140. void SetStandState( sStandName, nState )
141. number GetStandState( sStandName )
142. number GetStandStatesCount( sStandName )
143. void StopTrigger()
144. void PlayObjectAnimation( sObjectID, sAnimID, nAction )
  • 3.3. Тактический режим.
3.3.1 Общее положение дел.
3.3.2 Хуки.
145. bool DoPrepare()
146. bool DoStart()
147. bool UnitMove(sUnitName)
148. void UnitDeath(sUnitName)
3.3.3 Общие функции контроля боя.
149. void EnableDynamicBattleMode( bEnable )
150. void EnableAutoFinish( bEnable )
151. void combatEnableFinish( bEnable )
152. void EnableCinematicCamera( bEnable )
153. void SetControlMode( nSideID, nModeID )
154. void Finish( nSideID )
155. void Break()
156. void combatSetPause( n1, b1 )
157. void showHighlighting( bShow = true )
3.3.3 Управление юнитами.
158. void SummonCreature( nSideID, nCreatureID, nCount, nX = -1, nY = -1 )
159. void AddCreature( nSideID, nCreatureID, nCount, nX = -1, nY = -1 )
160. void addUnit(nCreatureID, nSideID, nX, nY, nCount, sUnitName)
161. void removeUnit( sUnitName )
162. void UnitCastAimedSpell( sUnitName, nSpellID, sTarget)
163. void UnitCastGlobalSpell( sUnitName, nSpellID )
164. void UnitCastAreaSpell( sUnitName, nSpellID, nX, nY )
165. void SetUnitManaPoints( sUnitName, nPoints )
166. number GetUnitMaxManaPoints( sUnitName )
167. number GetUnitManaPoints( sUnitName )
168. void commandDefend( sUnitName )
169. void commandDoSpell( sUnitName, nSpellID, nX, nY )
170. void commandShot( sUnitName, sVictimName, bDontShowScene = false )
171. void commandMove( sUnitName, nX, nY, bCheckPath = false )
172. void commandMoveAttack(sAttacker, sVictim, nX = -1, nY = -1, bCheckPath = false)
173. void commandDoSpecial(sUnitName, nAbilityID, nX = -1, nY = -1, bCheckPath = false)
174. void displace( sUnitName, nX, nY )
175. void playAnimation( sUnitName, sAnimType, nActionTypeID = ONESHOT )
176. void combatPlayEmotion( nSideID, n1 )
177. void RemoveAllUnits()
178. void setATB( sUnitName, n1 )
3.3.4 Информационные и прочие функции.
179. tsUnits GetUnits(nSideID, nType)
180. nCreatureID GetCreatureType( sCreatureName )
181. nX, nY pos( sUnitName )
182. bool combatStarted()
183. sHeroName GetHeroName( sUnitName )
184. number GetCreatureNumber( sUnitName )
185. nX, nY GetUnitPosition( sUnitName )
186. bool exist( sUnitName )
187. nHostType GetHost( nSideID )
188. nSideID GetUnitSide( sUnitName )
189. number GetUnitType( sUnitName )
190. number GetWarMachineType( sUnitName )
191. number GetBuildingType( sUnitName )
192. sUnitName combatReadyPerson()
193. string unitNames()
194. void postEvent( sEvent, n1 = -1, n2 = -1 )
  • 3.4. Режим города.
3.4.1 Хуки
195. void CreatureHired( nCreatureID, nCount )
196. void HeroHired( sHeroName )
3.4.2 Прочие функции

`
ОЖИДАНИЕ РЕКЛАМЫ...