21_1758508695"> Справочник по скриптовому API HoMM V, версия 1.3
Справочник по скриптовому API HoMM V, версия 1.3 1 1. Про всякое. 6 2. Немножко про LUA. 6 3. Реализация скрипт-системы в HoMMV. 11 3.1. Функции, доступные везде. 11 number sqrt( number ) 11 number mod( number1, number2 ) 11 number random( nHi ) 11 void sleep( nSegments ) 12 fProc parse( sToEval ) 12 void print( s1, s2, ... ) 12 void print_to( sFileName, v1, v2, ... ) 12 sFileName create_file( sFileName ) 12 sFileName open_file( sFileName ) 12 void _ERRORMESSAGE( sMsg ) 12 void errorHook( fCallback ) 13 void startThread( fProc, vParam1, vParam2, ... ) 13 void doFile( spFileLUA ) 14 nDifficulty GetDifficulty() 14 void consoleCmd( sCmd ) 14 void SetGameVar( sVarName, sValue ) 14 string GetGameVar( sVarName ) 14 void Save( sSaveName ) 14 void Load( sSaveName ) 14 void TutorialSetBlink( sID, nOn ) 14 void TutorialMessageBox( sID ) 14 bool IsTutorialMessageBoxOpen() 14 bool IsTutorialItemEnabled( sID ) 14 void TutorialActivateHint( sID ) 14 void TutorialSetBlink( sID, nBlink ) 14 3.2. Стратегический режим. 15 3.2.1 Общая работа с параметрами игрока. 15 nPlayerID GetCurrentPlayer() 15 nPlayerStateID GetPlayerState( nPlayerID ) 15 number GetPlayerResource( nPlayerID, nResID ) 15 void SetPlayerResource( nPlayerID, nResID, nCount ) 15 void SetPlayerStartResources( nPlayerID, nWoodCnt, nOreCnt, nMercuryCnt, nCrystalCnt, nSulfurCnt, nGemCnt, nGoldCnt ) 15 tsHeroes GetPlayerHeroes( nPlayerID ) 16 void SetPlayerHeroesCountNotForHire( nPlayerID, nCount ) 16 nPlayerID GetObjectOwner( sObjectName ) 16 void SetObjectOwner( sObjectName, nPlayerID ) 16 bool IsObjectVisible( nPlayerID, sObjectName ) 16 void OpenCircleFog( nX, nY, nFloorID, nRadius, nPlayerID ) 16 3.2.2 Работа с объективами (или с обжективами – кому как). 16 nState GetObjectiveState( sObjectiveName, nPlayerID = PLAYER_1 ) 16 void SetObjectiveState( sObjectiveName, nState, nPlayerID = PLAYER_1 ) 17 nProgress GetObjectiveProgress( sObjectiveName, nPlayerID = PLAYER_1 ) 17 void SetObjectiveProgress( sObjectiveName, nProgress, nPlayerID = PLAYER_1 ) 17 bool IsObjectiveVisible( sObjectiveName, nPlayerID = PLAYER_1 ) 17 void SetObjectiveVisible( sObjectiveName, bVisible, nPlayerID = PLAYER_1 ) 17 3.2.3 Работа с ключами. 17 bool HasBorderguardKey( nPlayerID, nKeyID ) 17 void GiveBorderguardKey( nPlayerID, nKeyID ) 17 3.2.4 Работа с регионами. 18 void SetRegionBlocked( sRegionName, bEnable, nPlayerID = -1 ) 18 bool IsRegionBlocked( sRegionName, nPlayerID ) 18 tsObjects GetObjectsInRegion( sRegionName, nObjectsTypeID ) 18 nX, nY, nFloorID RegionToPoint( sRegionName ) 18 bool IsObjectInRegion( sHeroName, sRegionName ) 18 void OpenRegionFog( nPlayerID, sRegionName ) 18 3.2.5 Работа с AI. 18 void SetAIPlayerAttractor( sObjectName, nPlayerID, nPriority ) 18 void SetAIHeroAttractor( sObjectName, sHeroName, nPriority ) 19 void EnableHeroAI( sHeroName, bEnable ) 19 void MoveHero( sHeroName, nX, nY, nFloorID = -1 ) 19 bool CanMoveHero( sHeroName, nX, nY, nFloorID = -1 ) 19 void EnableAIHeroHiring( nPlayerID, sTownName, bEnable ) 19 3.2.6 Работа с героями. 19 nCount GetHeroStats(HeroName, nStatID) 19 void ChangeHeroStat( sHeroName, nStatID, nDelta ) 19 bool HasHeroSkill( sHeroName, nSkillID ) 20 bool GiveHeroSkill( sHeroName, nSkillID ) 20 void KnowHeroSpell( sHeroName, nSpellID ) 20 void TeachHeroSpell( sHeroName, nSpellID ) 20 bool LevelUpHero( sHeroName ) 20 nLevel GetHeroLevel( sHeroName ) 20 bool IsHeroAlive( sHeroName ) 20 void DeployReserveHero( sHeroName, nX, nY, nFloorID = GROUND ) 21 void UnreserveHero( sHeroName ) 21 nCost CalcHeroMoveCost( sHeroName, nX, nY, nFloorID = -1 ) 21 void MoveHeroRealTime( sHeroName, nX, nY, nFloorID = -1 ) 21 nCount GetHeroCreatures( sHeroName, nCreatureID ) 21 void AddHeroCreatures( sHeroName, nCreateureID, nCount ) 21 void RemoveHeroCreatures( sHeroName, nCreatureID, nCount ) 21 void GiveArtefact( sHeroName, nArtID, nBindToHero = 0 ) 22 bool HasArtefact(sHeroName, nArtID) 22 void RemoveArtefact( sHeroName, nArtID ) 22 void SetHeroLootable( sHeroName, bEnable ) 22 bool IsHeroLootable( sHeroName ) 22 void MarkObjectAsVisited( sObjectName, sHeroName ) 22 sTownName GetHeroTown( sHeroName ) 22 sHeroName GetTownHero( sTownName ) 22 tsObjects GetObjectsFromPath( sHeroName, nX, nY, nFloorID = -1 ) 23 void GiveHeroWarMachine( sHeroName, nWarMachineID ) 23 void HasHeroWarMachine( sHeroName, nWarMachineID ) 23 bool RemoveHeroWarMachine( sHeroName, nWarMachineID ) 23 void StartCombat( sHeroName, sEnemyHeroName, nEnemyIDCount, nCreatureID1, nCount1, nCreatureID2, nCount2, ..., spScriptXDB, sFinishProc, spAdventureFlybySceneXDB = nil ) 23 void SetHeroCombatScript( sHeroName, spScriptXDB ) 24 void ResetHeroCombatScript( sHeroName ) 24 void SiegeTown( sHeroName, spAdvMapTownXDB, spAdventureFlybySceneXDB = nil ) 24 3.2.6 Работа с городами. 24 nLevel GetTownBuildingLevel( sTownName, nBuildingID ) 24 nLevel GetTownBuildingLimitLevel( sTownName, nBuildingID ) 24 nLevel GetTownBuildingMaxLevel( sTownName, nBuildingID ) 24 void SetTownBuildingLimitLevel( sTownName, nBuildingID, nLevel ) 24 void TransformTown( sTownName, nTownTypeID ) 24 void RazeTown( sTownName ) 25 3.2.7 Работа с объектами. 25 nX, nY, nFloorID GetObjectPosition( sObjectName ) 25 void SetObjectPosition( sObjectName, nX, nY, nFloorID = -1 ) 25 void RemoveObject( sObjectName ) 25 bool IsObjectExists( sObjectName ) 25 bool IsObjectEnabled( sObjectName ) 25 void SetObjectEnabled( sObjectName, bEnable ) 26 tsObjects GetObjectNamesByType( sObjectTypeSubstr ) 26 void AddObjectCreatures( sObjectName, nGreatureID, nCount ) 26 nCount GetObjectCreatures( sObjectName, nCreatureID ) 26 void RemoveObjectCreatures( sObjectName, nCreatureID, nCount ) 26 void SetObjectDwellingCreatures( sObjectName, nCreatureID, nCount ) 26 nCount GetObjectDwellingCreatures( sTownName, nCreatureID ) 26 void CreateArtifact( sArtName, nArtID, nX, nY, nFloorID ) 26 void ShowFlyingSign( spTXT, sObjectName, nPlayerID = -1, nTimeSec = 1.0) 26 void CreateMonster( sMonsterName, nCreatureID, nCount, nX, nY, nFloorID, nMonsterMoodID, nCreatureCourageID ) 27 void RemoveAllMonsters( nCreatureID ) 27 void GenerateMonsters( nCreatureID, nCountGroupsMin, nCountGroupsMax, nCountInGroupMin, nCountInGroupMax ) 27 3.2.8 Работа с интерфейсом. 27 void QuestionBox( spTXT, sCallback ) 27 void StartDialogScene( spDialogSceneXDB, sCallback = nil, sSaveName = nil ) 28 void StartCutScene( sAnimSceneXDB, sCallback = nil, saveName = nil ) 28 void MessageBox( spTXT, sCallback = nil, sSaveName = nil ) 28 void StartDialogSceneInt( spDialogSceneXDB, sCallback, sSaveName ) 28 void StartCutSceneInt( spAnimSceneXDB, sCallback, sSaveName ) 28 void MessageBoxInt(spTXT, sCallback, sSaveName) 28 void MoveCamera( nX, nY, nFloorID, nZoom = 50, nPitch = pi/2, nYawl = 0, nNoZoom = 0, nNoRotate = 0 ) 28 3.2.9 Функции общей направленности. 29 void Loose() 29 void Win() 29 void BlockGame() 29 void UnblockGame() 29 void ExitGame() 29 number GetDate( nDateID ) 29 nX, nY GetTerrainSize() 29 number GetMaxFloor() 29 bool IsTilePassable( nX, nY, nFloorID = GROUND ) 29 string GetAllNames( nFilterCode ) 30 void SetWarfogBehaviour( nOnLand, nOnSea ) 30 void Trigger(nTriggerType, ...) 30 3.2.10 Работа со звуком. 33 nSoundID Play3DSound( spSoundXDB, nX, nY, nFloorID ) 33 nSoundID Play2DSound( spSoundXDB ) 33 void StopPlaySound( nSoundID ) 33 3.2.11 Работа с освещением. 33 void SetCombatAmbientLight( spAmbientLightXDB ) 33 void SetObjectFlashlight( sObjectName, sLightID ) 33 void SetAmbientLight( nFloorID, sLightID, bFade = false, nTime = 1) 33 3.2.12 Всякие непонятки. 33 number CalcAverageMonstersTier() 33 tnTier GetGuardsTier( sObjectName ) 33 void SetStandState( sStandName, nState ) 34 number GetStandState( sStandName ) 34 number GetStandStatesCount( sStandName ) 34 void StopTrigger() 34 void PlayObjectAnimation( sObjectID, sAnimID, nAction ) 34 3.3. Тактический режим. 34 3.3.1 Общее положение дел. 34 3.3.2 Хуки. 35 bool DoPrepare() 35 bool DoStart() 35 bool UnitMove(sUnitName) 35 void UnitDeath(sUnitName) 35 3.3.3 Общие функции контроля боя. 36 void EnableDynamicBattleMode( bEnable ) 36 void EnableAutoFinish( bEnable ) 36 void combatEnableFinish( bEnable ) 36 void EnableCinematicCamera( bEnable ) 36 void SetControlMode( nSideID, nModeID ) 36 void Finish( nSideID ) 36 void Break() 36 void combatSetPause( n1, b1 ) 37 void showHighlighting( bShow = true ) 37 3.3.3 Управление юнитами. 37 void SummonCreature( nSideID, nCreatureID, nCount, nX = -1, nY = -1 ) 37 void AddCreature( nSideID, nCreatureID, nCount, nX = -1, nY = -1 ) 37 void addUnit(nCreatureID, nSideID, nX, nY, nCount, sUnitName) 37 void removeUnit( sUnitName ) 37 void UnitCastAimedSpell( sUnitName, nSpellID, sTarget) 38 void UnitCastGlobalSpell( sUnitName, nSpellID ) 38 void UnitCastAreaSpell( sUnitName, nSpellID, nX, nY ) 38 void SetUnitManaPoints( sUnitName, nPoints ) 38 number GetUnitMaxManaPoints( sUnitName ) 38 number GetUnitManaPoints( sUnitName ) 38 void commandDefend( sUnitName ) 38 void commandDoSpell( sUnitName, nSpellID, nX, nY ) 39 void commandShot( sUnitName, sVictimName, bDontShowScene = false ) 39 void commandMove( sUnitName, nX, nY, bCheckPath = false ) 39 void commandMoveAttack(sAttacker, sVictim, nX = -1, nY = -1, bCheckPath = false) 39 void commandDoSpecial(sUnitName, nAbilityID, nX = -1, nY = -1, bCheckPath = false) 39 void displace( sUnitName, nX, nY ) 40 void playAnimation( sUnitName, sAnimType, nActionTypeID = ONESHOT ) 40 void combatPlayEmotion( nSideID, n1 ) 40 void RemoveAllUnits() 40 void setATB( sUnitName, n1 ) 40 3.3.4 Информационные и прочие функции. 41 tsUnits GetUnits(nSideID, nType) 41 nCreatureID GetCreatureType( sCreatureName ) 41 nX, nY pos( sUnitName ) 41 bool combatStarted() 41 sHeroName GetHeroName( sUnitName ) 41 number GetCreatureNumber( sUnitName ) 41 nX, nY GetUnitPosition( sUnitName ) 41 bool exist( sUnitName ) 42 nHostType GetHost( nSideID ) 42 nSideID GetUnitSide( sUnitName ) 42 number GetUnitType( sUnitName ) 42 number GetWarMachineType( sUnitName ) 43 number GetBuildingType( sUnitName ) 43 sUnitName combatReadyPerson() 43 string unitNames() 43 void postEvent( sEvent, n1 = -1, n2 = -1 ) 43 3.4. Режим города. 44 3.4.1 Хуки 44 void CreatureHired( nCreatureID, nCount ) 44 void HeroHired( sHeroName ) 44 3.4.2 Прочие функции 44
|