//==================================================================================================
//
// natives.galaxy
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
// Achievements
//--------------------------------------------------------------------------------------------------
native bool AchievementsDisabled (int player);
//--------------------------------------------------------------------------------------------------
// Bank
//--------------------------------------------------------------------------------------------------
native void BankReload (bank b);
native void BankWait (bank b);
native void BankSectionCreate (bank b, string section);
//--------------------------------------------------------------------------------------------------
// Battle Report
//--------------------------------------------------------------------------------------------------
native int BattleReportGetDialogControl ();
native int BattleReportGetState (int inBattleReportId);
native int BattleReportGetPriority (int inBattleReportId);
native text BattleReportGetButtonText (int inBattleReportId);
native string BattleReportGetButtonImage (int inBattleReportId);
native text BattleReportGetMissionText (int inBattleReportId);
native text BattleReportGetResearchTitle (int inBattleReportId);
native text BattleReportGetResearchText (int inBattleReportId);
native text BattleReportGetBonusTitle (int inBattleReportId);
native text BattleReportGetBonusText (int inBattleReportId);
native text BattleReportGetBestTimeText (int inBattleReportId);
native string BattleReportGetMissionImage (int inBattleReportId);
native bool BattleReportGetDifficultyLevelCompleted (int inBattleReportId, int inDifficultyLevel);
native text BattleReportGetDifficultyLevelBestTimeText (int inBattleReportId, int inDifficultyLevel);
native text BattleReportGetSceneText (int inBattleReportId);
native string BattleReportGetSceneImage (int inBattleReportId);
native bool BattleReportGetShownInMissionTotal (int inBattleReportId);
//--------------------------------------------------------------------------------------------------
// Boards
//--------------------------------------------------------------------------------------------------
native void BoardSetAnchor (int inBoard, int inAnchor, int inOffsetX, int inOffsetY);
//--------------------------------------------------------------------------------------------------
// Campaign
//--------------------------------------------------------------------------------------------------
native void CampaignProgressDeleteCampaignSave (playergroup players); // Blizzard maps only
native void CampaignProgressEnableCampaignCompletedSaves (playergroup players, bool inDisable); // Blizzard maps only
//--------------------------------------------------------------------------------------------------
// Cutscenes
//--------------------------------------------------------------------------------------------------
native int CutsceneGetTriggerControl (int inControlId);
//--------------------------------------------------------------------------------------------------
// Dialogs
//--------------------------------------------------------------------------------------------------
const int c_triggerControlTypeCutscene = 22;
const int c_triggerControlPropertyHotkey = 65; // int
const int c_triggerControlPropertyAllowedButtons = 66; // int
const int c_triggerControlPropertyAlphaMask = 67; // string
const int c_triggerControlEventTypeHotkeyPressed = 8;
const int c_triggerControlEventTypeDoubleClick = 9;
native int DialogControlHookupUnitStatus (int type, string inTemplate, unit inUnit);
native void DialogControlClearSelectedItem (int control, playergroup players);
native int EventDialogControlMouseButton ();
//--------------------------------------------------------------------------------------------------
// Environment
//--------------------------------------------------------------------------------------------------
const int c_pathingUnpathable = 0;
const int c_pathingBuilding = 2;
const int c_pathingCliff = 3;
native int PathingType (point inPos);
//--------------------------------------------------------------------------------------------------
// Game
//--------------------------------------------------------------------------------------------------
native bool GameIsOnline ();
native bool GameDataIsFullyDownloaded (int player);
native void TriggerAddEventLoadGameDone (trigger t);
//--------------------------------------------------------------------------------------------------
// Melee
//--------------------------------------------------------------------------------------------------
const int c_meleeOptionPoints = 6;
//--------------------------------------------------------------------------------------------------
// Objectives
//--------------------------------------------------------------------------------------------------
native int ObjectiveGetPriority (int inObjective);
native void ObjectiveSetFirst (int inObjective);
native void ObjectiveSetLast (int inObjective);
native void ObjectiveSetAfter (int inObjective, int inAfterObjective);
native void ObjectiveSetBefore (int inObjective, int inBeforeObjective);
//--------------------------------------------------------------------------------------------------
// Path
//--------------------------------------------------------------------------------------------------
const int c_abilClassFilterExcluded = -1;
const int c_abilClassFilterAllowed = 0;
const int c_abilClassFilterRequired = 1;
native void PathSetAbilClassFilter (int inPathId, int inAbilClass, int inFilter);
//--------------------------------------------------------------------------------------------------
// Ping
//--------------------------------------------------------------------------------------------------
native void PingSetUseUnitTeamColor (int p, bool useUnitTeamColor);
native void PingSetUseUnitVisibility (int p, bool useUnitVisibility);
//--------------------------------------------------------------------------------------------------
// Help
//--------------------------------------------------------------------------------------------------
native void HelpPanelSetHelpItemDarkenedWhenViewed (int inHelpItemId, bool inDarkened);
//--------------------------------------------------------------------------------------------------
// Players
//--------------------------------------------------------------------------------------------------
const int c_playerPropDamageDealtTime = 18;
const int c_playerPropDamageTakenTime = 19;
const int c_playerStateStartingRallyEnabled = 17; // Read-only
const int c_buildMenuOpening = 1; // uses c_customBuildOpeningOne to c_customBuildOpeningFive for inSlotNum
const int c_buildMenuLateGame = 2; // uses c_customBuildLateGameOne to c_customBuildLateGameFive for inSlotNum
const int c_buildMenuBeacons = 3; // only used for SlotInfo setup, uses c_beaconCustom1 to c_beaconCustom4 for inSlotNum
native int PlayerAIBuildNumber (int player);
native bool PlayerHasAccessTo (int inPlayer, string inEntityName);
native void PlayerBeaconBuildMenuSetSlotInfo (int inPlayer, int inType, int inSlotNum, text inIcon, text inName, text inTooltip);
native void PlayerBeaconBuildMenuDisableSlotInfo (int inPlayer, int inType, int inSlotNum, bool disable); // disables the button
native void PlayerBeaconBuildMenuClearSlotInfo (int inPlayer, int inType, int inSlotNum); // removes the button
native void PlayerBeaconBuildMenuCurrentSet (int inPlayer, int inType, int inSlotNum); //only applies to build types
native int PlayerBeaconBuildMenuCurrentGet (int inPlayer, int inType); //only applies to build types
native bool PlayerBeaconBuildMenuWasFromPlayer (int inPlayer, int inType); //only applies to build types
//--------------------------------------------------------------------------------------------------
// Points
//--------------------------------------------------------------------------------------------------
native point PointFromName (string name);
//--------------------------------------------------------------------------------------------------
// Regions
//--------------------------------------------------------------------------------------------------
native region RegionFromName (string name);
//--------------------------------------------------------------------------------------------------
// Sound
//--------------------------------------------------------------------------------------------------
native void SoundChannelDSPInsert (playergroup players, int channel, string dsp);
native void SoundChannelDSPRemove (playergroup players, int channel, string dsp);
native void SoundtrackStopCurrent (playergroup players, int category, bool fade);
//--------------------------------------------------------------------------------------------------
// Story Mode
//--------------------------------------------------------------------------------------------------
native void StoryCreatePlanetPanel (); // Blizzard maps only
//--------------------------------------------------------------------------------------------------
// Tech Tree
//--------------------------------------------------------------------------------------------------
native void TechTreeSpecificRequirementEnable (int player, string requirementName, bool enable);
native bool TechTreeSpecificRequirementEnabled (int player, string requirementName);
//--------------------------------------------------------------------------------------------------
// Timing
//--------------------------------------------------------------------------------------------------
const int c_timerWindowImageBorder = 0;
const int c_timerWindowImageBackground = 1;
const int c_timerWindowImageProgressFrame = 2;
const int c_timerWindowImageProgressFill = 3;
native void TimerWindowSetAnchor (int inWindow, int inAnchor, int inOffsetX, int inOffsetY);
native void TimerWindowSetFixedHeight (int inWindow, int inHeight);
native void TimerWindowShowBorder (int inWindow, bool inShow);
native void TimerWindowShowProgressBar (int inWindow, bool inShow);
native void TimerWindowSetProgressColor (int inWindow, color inColor, int inStep);
native void TimerWindowSetImageType (int inWindow, int inImage, int inType);
//--------------------------------------------------------------------------------------------------
// Transmission
//--------------------------------------------------------------------------------------------------
native void TransmissionSourceSetStreamingAllowed (transmissionsource source, bool allowed);
//--------------------------------------------------------------------------------------------------
// Triggers
//--------------------------------------------------------------------------------------------------
// Generic trigger event that can be sent via script
// NOTE: This was my idea; I'm pretty awesome.
native void TriggerSendEvent (string name);
native void TriggerAddEventGeneric (trigger t, string name);
native string EventGenericName ();
native void TriggerDebugEnableType (int type, bool enable);
//--------------------------------------------------------------------------------------------------
// Units
//--------------------------------------------------------------------------------------------------
const int c_killDisplayDefault = 0;
const int c_killDisplayAlways = 1;
const int c_killDisplayNever = 2;
const int c_unitBehaviorFlagUpdateDurationWhileDisabled = 10;
const int c_placementTestCreepMask = 1 << c_placementTestCreep;
const int c_placementTestPowerMask = 1 << c_placementTestPower;
const int c_placementTestFogMask = 1 << c_placementTestFog;
const int c_placementTestIgnoreBlockersMask = 1 << c_placementTestIgnoreBlockers;
const int c_placementTestIgnoreInvisibleMask = 1 << c_placementTestIgnoreInvisible;
const int c_placementTestZoneMask = 1 << c_placementTestZone;
const int c_placementTestCliffMask = 1 << c_placementTestCliff;
const int c_placementTestDensityMask = 1 << c_placementTestDensity;
const int c_unitAbilAutoCastChangeAll = -1;
const int c_unitAbilAutoCastChangeOff = 0;
const int c_unitAbilAutoCastChangeOn = 1;
native void UnitShowKillDisplay (unit inUnit, int inKillDisplay);
native void UnitSetInfoText2 (unit inUnit, text info);
native void UnitSetInfoTip (unit inUnit, text tip);
native void UnitSetInfoSubTip (unit inUnit, text subTip);
native unit UnitMagazineLastCreated ();
native unitgroup UnitMagazineLastCreatedGroup ();
native void UnitInventoryContainerOpen (playergroup inPlayers, unit inUnit, int inContainer, bool inOpen);
native point UnitTypePlacementTestsFromPoint (string inType, int inPlayer, point inSource, fixed inRange, int inTests);
native point UnitTypePlacementTestsFromUnit (string inType, int inPlayer, unit inSource, fixed inRange, int inTests);
native void UnitEventSetNullVariableInvalid (bool inVal);
native void TriggerAddEventUnitStartedAttack2 (trigger t, unitref u, string inWeapon);
native void TriggerAddEventUnitAttacked2 (trigger t, unitref u, string inWeapon);
native string EventUnitGetWeapon ();
native fixed EventUnitDamageAbsorbed ();
native unit EventUnitGetItem ();
native string EventUnitGetItemType ();
native void TriggerAddEventUnitAbilityAutoCastChange (trigger t, unitref u, abilcmd a, int inChangeType, bool includeSharedAbils);
//--------------------------------------------------------------------------------------------------
// Unit Groups
//--------------------------------------------------------------------------------------------------
native int UnitCount (string type, int player, region r, unitfilter filter, int maxCount);
native int UnitCountAlliance (int player, int alliance, region r, unitfilter filter, int maxCount);
//--------------------------------------------------------------------------------------------------
// User Interface
//--------------------------------------------------------------------------------------------------
const int c_mouseButtonFlagLeft = (1 << 0);
const int c_mouseButtonFlagMiddle = (1 << 1);
const int c_mouseButtonFlagRight = (1 << 2);
const int c_mouseButtonFlagXButton1 = (1 << 3);
const int c_mouseButtonFlagXButton2 = (1 << 4);
const int c_achievementToastStyleTerran = 0;
const int c_achievementToastStyleZerg = 1;
const int c_syncFrameTypeStatusUI = 35;
const int c_syncFrameTypeArmyButton = 36;
const int c_gameMenuDialogLoadReplayButton = 20; // unused
const int c_gameMenuDialogLoadLastButton = 21;
const int c_gameMenuDialogMoreOptionsButton = 22;
const int c_gameMenuDialogEndGameButton = 23;
const int c_gameMenuDialogAchievementsButton = 24;
const int c_gameMenuDialogMessageLogButton = 25;
const int c_localSelectionTypeArmyButton = 9;
const int c_targetModeStateAny = -1;
const int c_targetModeStateOff = 0;
const int c_targetModeStateOn = 1;
native void UISetMinimumLetterboxHeight (int inHeight);
native void UISetAchievementToastStyle (playergroup inPlayers, int style);
native void TriggerAddEventTargetModeUpdate (trigger t, int player, abilcmd inAbilCmd, int state);
native abilcmd EventTargetModeAbilCmd ();
native int EventTargetModeState ();
//--------------------------------------------------------------------------------------------------
// Visibility
//--------------------------------------------------------------------------------------------------
native bool VisIsVisibleForPlayer (int player, point inPos);
//==================================================================================================
//
// AI.galaxy
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
// Build and Train Priorities
//--------------------------------------------------------------------------------------------------
const int c_makePriorityDetection = 8;
const int c_makePriorityFood = 9;
//--------------------------------------------------------------------------------------------------
// Town States
//--------------------------------------------------------------------------------------------------
const int c_townStateBuilding = 2;
//--------------------------------------------------------------------------------------------------
// Wave States
//--------------------------------------------------------------------------------------------------
const int c_waveStateBeacon = 12;
//--------------------------------------------------------------------------------------------------
// Best Target Flags
//--------------------------------------------------------------------------------------------------
const int c_btSortMeleeAllyAttackOnly = 256; // chooses the best target only considering already attacking computer allies
const int c_btSortMeleeAllyDefendOnly = 512; // chooses the best target only considering computer allies that want help defending
const int c_btMeleePreferSplitAttacking = 1024; // melee AI will each try to hit different opponents rather than attacking the same target (weaker AI, but more fun to play against) (ignored for more than 2 teams)
const int c_btDefaultAllyAttackOnly = 1 + 16 + 32 + 128 + 256;
const int c_btDefaultAllyDefendOnly = 1 + 16 + 32 + 128 + 512;
//--------------------------------------------------------------------------------------------------
// Difficulty
//--------------------------------------------------------------------------------------------------
const int c_diffLimitAPMCombat = 7; // If we're not limiting all APM, do we still limit combat APM (has no effect if c_diffLimitAPM is Enabled since combat is limited by that).
const int c_diffAdvancedRetreatLogic = 20; // Controls whether the AI uses advanced logic when retreating (does a calculation to see if the enemy has faster unit that will continue to attack us while we retreat).
const int c_diffAutoTransport = 31; // Should transports automatically look for units unable to move to their goal and pick them up? (worker trying to expand to an island, etc).
const int c_skirAuto = 0; // melee difficulty settings
const int c_skirMed_Hard = 4;
const int c_skirHard_VH = 6;
const int c_skirChVision = 8;
const int c_skirChMoney = 9;
const int c_skirChInsane = 10;
//--------------------------------------------------------------------------------------------------
// Utility
//--------------------------------------------------------------------------------------------------
native void AISetCompNameToDiff (int player, int difficulty);
native void AISetStockArmyDefaultScale (int player, fixed scale); // Sets the gloabl scale (doesn't change current army)
native void AISetStockArmyOverride (int player, string data, int replaceCount, string replaceUnit);
native void AIAddToStockArmy (int player, string data, int change); // AIAddStringInt with Scale & Override logic
native void AIScaleCurrentStockArmy (int player, fixed scale, int start, int end); // Scales the current army
// these calls can be expensive, they also ignore units/buildings when pathing. returns -1 if no path/known building
native int AIPathDistToNearestKnownEnemyStructure (int player, point loc, bool onlyDropoffs);
native int AIPathDistToNearestFriendlyStructure (int player, point loc, bool onlyDropoffs);
native bool AICanPathToAnyKnownEnemyStructure (int player, point loc, bool onlyDropoffs);
// all of these are known buildings only (enemies may have unknown buildings)
native int AINumEnemyBuildings (int player);
native void AIAddAirDanger (int player, string unitType);
native bool AIDefaultSuspectAirDanger (int player);
native int AIGetNumTeams (); // may not be accurate outside of regular melee games
native int AIGetSelfRaceVal (int player);
native int AIGetNumWorkers (int player);
native int AIGetNumDropoffs (int player);
native int AIGetNumEstablishedTowns (int player);
native bool AIHasNearbyAlliedAttackers (int player, point loc, fixed range); // self or ally
native bool AIHasNearbyAlliedDetector (int player, point loc, fixed staticRange, fixed mobileRange); // self or ally
//--------------------------------------------------------------------------------------------------
// Coop Helper Functions
//--------------------------------------------------------------------------------------------------
const int c_coopTraining = 0;
const int c_coopWaveDefender = 1;
const int c_coopWaveAttacker = 2;
const int c_coopTurtle = 3;
const int c_coopCasterOnly = 4;
const int c_coopAirOnly = 5;
const int c_coopMultiRacial = 6;
native void AISetCoopFlag (int player, int index, bool state);
native bool AIGetCoopFlag (int player, int index);
native point AIGetBuildingPlacement (int player, point center, string aliasUnitType, int buildFlags);
//--------------------------------------------------------------------------------------------------
// Construction
//--------------------------------------------------------------------------------------------------
native int AIGetInternalTrainQueueCount (int player);
native int AIGetInternalBuildQueueCount (int player);
native int AIGetInternalResearchQueueCount (int player);
native void AISetDefaultArmyUnit (int player, string unitType);
native void AIForceTrainingDelay (int player, int workerDelay, int armyDelay, int defenseDelay); // forced gaps in unit production for low difficulty
//--------------------------------------------------------------------------------------------------
// Stock
//--------------------------------------------------------------------------------------------------
const int c_stockNormal = 0;
const int c_stockOptional = 1;
const int c_stockExpansion = 2;
const int c_stockDefense = 4;
const int c_stockForced = 8;
//--------------------------------------------------------------------------------------------------
// Tactical
//--------------------------------------------------------------------------------------------------
native point AISelfReinforceDropPoint (int player);
native void AIForceTacticalDelay (int player, int delay); // forced delay between all tactical spells for low difficulty
//--------------------------------------------------------------------------------------------------
// Combat
//--------------------------------------------------------------------------------------------------
native void AISetSpawnerTargettingDelay (int player, string behaviorName, int count);
//--------------------------------------------------------------------------------------------------
// Transports
//--------------------------------------------------------------------------------------------------
native void AITransportDisableAutoPickup (int player);
//--------------------------------------------------------------------------------------------------
// Waves
//--------------------------------------------------------------------------------------------------
native unit AIWaveCurrentLeader (wave w);
native wavetarget AIWaveTargetMeleeBeacon (int player);
native int AIEvalAllSelf (int player);
native int AIEvalAllAllied (int player);
native int AIEvalLargestEnemy (int player);