Actionscript game engine reference
Jump to navigation
Jump to search
Game
globals.Game.
- Time() - raw time since the server started. This continues even when the game is paused
- GetGameTime() - similar to Time, but freezes if the game is paused
- IsHUDFlipped() - Returns true if the user has enabled flipped HUD
- ScreenXYToWorld(x, y) - Converts the specified x,y screen co-ordinates into x,y,z world co-ordinates. Returns array with the translated x,y,z world co-ordinate(x is 0, y is 1 and z is 2).
- WorldToScreenX( x, y, z ) - Converts the specified x,y,z world co-ordinate into an x screen coordinate. Returns -1 if offscreen
- WorldToScreenY( x, y, z ) - Converts the specified x,y,z world co-ordinate into a y screen coordinate. Returns -1 if offscreen
- GetKeybindForAbility( nAbilityEntityIndex ) - Returns the keybind as a string
- GetState() - returns the current gamerules state:
- DOTA_GAMERULES_STATE_INIT = 0,
- DOTA_GAMERULES_STATE_WAIT_FOR_PLAYERS_TO_LOAD = 1,
- DOTA_GAMERULES_STATE_HERO_SELECTION = 2,
- DOTA_GAMERULES_STATE_STRATEGY_TIME = 3,
- DOTA_GAMERULES_STATE_PRE_GAME = 4,
- DOTA_GAMERULES_STATE_GAME_IN_PROGRESS = 5,
- DOTA_GAMERULES_STATE_POST_GAME = 6,
- DOTA_GAMERULES_STATE_DISCONNECT = 7,
- DOTA_GAMERULES_STATE_TEAM_SHOWCASE = 8,
- DOTA_GAMERULES_STATE_LAST = 9
Players
globals.Players.
- CanPlayerBuyback( nPlayerID ) - Can the player buy back?
- GetAssists( nPlayerID ) - The number of assists credited to a player.
- GetClaimedDenies( nPlayerID ) -
- GetClaimedMisses( nPlayerID ) -
- GetDeaths( nPlayerID ) - The number of deaths a player has suffered.
- GetDenies( nPlayerID ) - The number of denies credited to a player.
- GetGold( nPlayerID ) - The amount of gold a player has.
- GetGoldBagsCollected( nPlayerID ) - The number of gold bags collected by a player.
- GetKills ( nPlayerID ) - The number of kills credited to a player.
- GetLastBuybackTime( nPlayerID ) -
- GetLastHitMultikill( nPlayerID ) -
- GetLastHits( nPlayerID ) - The number of last hits credited to a player.
- GetLastHitStreak( nPlayerID ) -
- GetLevel( nPlayerID ) - The current level of a player.
- GetMisses( nPlayerID ) -
- GetNearbyCreepDeaths( nPlayerID ) -
- GetReliableGold( nPlayerID ) - Total reliable gold for this player.
- GetRespawnSeconds( nPlayerID ) -
- GetStreak( nPlayerID ) -
- GetTotalEarnedGold( nPlayerID ) - Total gold earned in this game by this player.
- GetTotalEarnedXP( nPlayerID ) - Total xp earned in this game by this player.
- GetUnreliableGold( nPlayerID ) - Total unreliable gold for this player.
- GetGoldPerMin( nPlayerID ) - Average gold earned per minute for this player.
- GetXPPerMin( nPlayerID ) - Average xp earned per minute for this player.
- GetMaxPlayers( nPlayerID ) - Get the maximum number of players in the game.
- GetMaxTeamPlayers( nPlayerID ) - Get the maximum number of players on teams.
- GetLocalPlayer() - Get the local player ID.
- IsValidPlayer( nPlayerID ) - Is the nth player a valid player?
- GetPlayerName( nPlayerID ) - Return the name of a player.
- GetPlayerSelectedHero( nPlayerID ) - Return the name of the hero a player is controlling.
- GetPlayerHeroEntityIndex( nPlayerID ) - Get the entity index of the hero controlled by this player.
- GetSelectedEntities( nPlayerID ) - Get the entities this player has selected (as an array of entity indices).
- GetQueryUnit( nPlayerID ) - Get the entities this player is querying (as an array of entity indices).
- GetPlayerColor( nPlayerID ) - Get the player color.
- IsSpectator( nPlayerID ) - Is this player a spectator.
Entities
These functions return an array of entity indices.
globals.Entities.
- GetAllBuildingEntities() - Get all the building entities.
- GetAllHeroEntities() - Get all the hero entities.
- GetAllCreatureEntities() - Get all the creature entities.
- GetAllEntitiesByName( name ) - Get all the entities with a given name.
- GetAllEntitiesByClassname( classname ) - Get all the entities with a given classname.
- GetAllEntities() - Get all the entities.
NPC
Given an NPC entity index, these functions return various information about the NPC.
globals.Entities.
- GetAbsOrigin( nNPCEntityIndex ) - Get the world origin of the entity.
- CanBeDominated( nNPCEntityIndex ) -
- HasAttackCapability( nNPCEntityIndex ) -
- HasCastableAbilities( nNPCEntityIndex ) -
- HasFlyingVision( nNPCEntityIndex ) -
- HasFlyMovementCapability( nNPCEntityIndex ) -
- HasGroundMovementCapability( nNPCEntityIndex ) -
- HasMovementCapability( nNPCEntityIndex ) -
- HasScepter( nNPCEntityIndex ) -
- HasUpgradeableAbilities( nNPCEntityIndex ) -
- HasUpgradeableAbilitiesThatArentMaxed( nNPCEntityIndex ) -
- IsAncient( nNPCEntityIndex ) -
- IsAttackImmune( nNPCEntityIndex ) -
- IsBarracks( nNPCEntityIndex ) -
- IsBlind( nNPCEntityIndex ) -
- IsBlockDisabled( nNPCEntityIndex ) -
- IsBoss( nNPCEntityIndex ) -
- IsRoshan( nNPCEntityIndex ) -
- IsBuilding( nNPCEntityIndex ) -
- IsCommandRestricted( nNPCEntityIndex ) -
- IsConsideredHero( nNPCEntityIndex ) -
- IsControllableByAnyPlayer( nNPCEntityIndex ) -
- IsCourier( nNPCEntityIndex ) -
- IsCreature( nNPCEntityIndex ) -
- IsCreep( nNPCEntityIndex ) -
- IsCreepHero( nNPCEntityIndex ) -
- IsDeniable( nNPCEntityIndex ) -
- IsDominated( nNPCEntityIndex ) -
- IsEnemy( nNPCEntityIndex ) -
- IsEvadeDisabled( nNPCEntityIndex ) -
- IsFort( nNPCEntityIndex ) -
- IsFrozen( nNPCEntityIndex ) -
- IsGeneratedByEconItem( nNPCEntityIndex ) -
- IsGreevil( nNPCEntityIndex ) -
- IsHallofFame( nNPCEntityIndex ) -
- IsHardDisarmed( nNPCEntityIndex ) -
- IsHero( nNPCEntityIndex ) -
- IsHexed( nNPCEntityIndex ) -
- IsIllusion( nNPCEntityIndex ) -
- IsInRangeOfFountain( nNPCEntityIndex ) -
- IsInventoryEnabled( nNPCEntityIndex ) -
- IsInvisible( nNPCEntityIndex ) -
- IsInvulnerable( nNPCEntityIndex ) -
- IsLaneCreep( nNPCEntityIndex ) -
- IsLootGreevil( nNPCEntityIndex ) -
- IsLowAttackPriority( nNPCEntityIndex ) -
- IsMagicImmune( nNPCEntityIndex ) -
- IsMechanical( nNPCEntityIndex ) -
- IsMuted( nNPCEntityIndex ) -
- IsNeutralUnitType( nNPCEntityIndex ) -
- IsNightmared( nNPCEntityIndex ) -
- IsOther( nNPCEntityIndex ) -
- IsOutOfGame( nNPCEntityIndex ) -
- IsOwnedByAnyPlayer( nNPCEntityIndex ) -
- IsPhantom( nNPCEntityIndex ) -
- IsRangedAttacker( nNPCEntityIndex ) -
- IsRealHero( nNPCEntityIndex ) -
- IsRooted( nNPCEntityIndex ) -
- IsSelectable( nNPCEntityIndex ) -
- IsShop( nNPCEntityIndex ) -
- IsSilenced( nNPCEntityIndex ) -
- IsSoftDisarmed( nNPCEntityIndex ) -
- IsSpeciallyDeniable( nNPCEntityIndex ) -
- IsStunned( nNPCEntityIndex ) -
- IsSummoned( nNPCEntityIndex ) -
- IsTower( nNPCEntityIndex ) -
- IsUnselectable( nNPCEntityIndex ) -
- IsWard( nNPCEntityIndex ) -
- IsZombie( nNPCEntityIndex ) -
- NoHealthBar( nNPCEntityIndex ) -
- NoTeamMoveTo( nNPCEntityIndex ) -
- NoTeamSelect( nNPCEntityIndex ) -
- NotOnMinimap( nNPCEntityIndex ) -
- NotOnMinimapForEnemies( nNPCEntityIndex ) -
- NoUnitCollision( nNPCEntityIndex ) -
- PassivesDisabled( nNPCEntityIndex ) -
- ProvidesVision( nNPCEntityIndex ) -
- UsesHeroAbilityNumbers( nNPCEntityIndex ) -
- GetAbilityCount( nNPCEntityIndex ) -
- GetCombatClassAttack( nNPCEntityIndex ) -
- GetCombatClassDefend( nNPCEntityIndex ) -
- GetCurrentVisionRange( nNPCEntityIndex ) -
- GetDamageBonus( nNPCEntityIndex ) -
- GetDamageMax( nNPCEntityIndex ) -
- GetDamageMin( nNPCEntityIndex ) -
- GetDayTimeVisionRange( nNPCEntityIndex ) -
- GetHealth( nNPCEntityIndex ) -
- GetHealthPercent( nNPCEntityIndex ) -
- GetHealthThinkRegen( nNPCEntityIndex ) -
- GetLevel( nNPCEntityIndex ) -
- GetMaxHealth( nNPCEntityIndex ) -
- GetNightTimeVisionRange( nNPCEntityIndex ) -
- GetStates( nNPCEntityIndex ) -
- GetTotalPurchasedUpgradeGoldCost( nNPCEntityIndex ) -
- GetTotalDamageTaken( nNPCEntityIndex ) -
- GetAttackRange( nNPCEntityIndex ) -
- GetAttackSpeed( nNPCEntityIndex ) -
- GetAttacksPerSecond( nNPCEntityIndex ) -
- GetBaseAttackTime( nNPCEntityIndex ) -
- GetBaseMagicalResistanceValue( nNPCEntityIndex ) -
- GetBaseMoveSpeed( nNPCEntityIndex ) -
- GetCollisionPadding( nNPCEntityIndex ) -
- GetEffectiveInvisibilityLevel( nNPCEntityIndex ) -
- GetHasteFactor( nNPCEntityIndex ) -
- GetHullRadius( nNPCEntityIndex ) -
- GetIdealSpeed( nNPCEntityIndex ) -
- GetIncreasedAttackSpeed( nNPCEntityIndex ) -
- GetMana( nNPCEntityIndex ) -
- GetManaThinkRegen( nNPCEntityIndex ) -
- GetMaxMana( nNPCEntityIndex ) -
- GetPaddedCollisionRadius( nNPCEntityIndex ) -
- GetPercentInvisible( nNPCEntityIndex ) -
- GetProjectileCollisionSize( nNPCEntityIndex ) -
- GetRingRadius( nNPCEntityIndex ) -
- GetSecondsPerAttack( nNPCEntityIndex ) -
- ManaFraction( nNPCEntityIndex ) -
- GetClassname( nNPCEntityIndex ) -
- GetDisplayedUnitName( nNPCEntityIndex ) -
- GetSelectionGroup( nNPCEntityIndex ) -
- GetSoundSet( nNPCEntityIndex ) -
- GetUnitLabel( nNPCEntityIndex ) -
- GetUnitName( nNPCEntityIndex ) -
- IsControllableByPlayer( nNPCEntityIndex, nPlayerID ) -
- GetChosenTarget( nNPCEntityIndex ) -
- HasItemInInventory( nNPCEntityIndex, item_name ) -
- GetRangeToUnit( nNPCEntityIndex ) -
- GetMoveSpeedModifier( nNPCEntityIndex, flBaseSpeed ) -
- CanAcceptTargetToAttack( nNPCEntityIndex ) -
- IsEntityInRange( nNPCEntityIndex, nOtherEntityIndex, flRange ) -
- InState( nNPCEntityIndex ) -
- GetArmorForDamageType( nNPCEntityIndex, nDamageType ) -
- GetArmorReductionForDamageType( nNPCEntityIndex, nDamageType ) -
- IsInRangeOfShop( nNPCEntityIndex ) -
- GetNumItemsInStash( nNPCEntityIndex ) -
- GetNumItemsInInventory( nNPCEntityIndex ) -
- GetItemInSlot( nNPCEntityIndex, nItemSlot ) - returns entity index of item
- GetAbility( nNPCEntityIndex, nAbilitySlot ) - returns entity index of ability
- GetAbilityByName( nNPCEntityIndex, ability_name ) - returns entity index of ability
- GetClassname( nNPCEntityIndex ) -
- GetDisplayedUnitName( nNPCEntityIndex ) -
- GetSelectionGroup( nNPCEntityIndex ) -
- GetSoundSet( nNPCEntityIndex ) -
- GetUnitLabel( nNPCEntityIndex ) -
- GetUnitName( nNPCEntityIndex ) -
- GetTotalDamageTaken( nNPCEntityIndex ) -
Ability
Given an ability entity index (returned from npc.GetAbility or npc.GetAbilityByName), these functions return information about the ability.
globals.Abilities.
- GetAbilityName( nAbilityEntityIndex ) -
- GetAbilityTextureName( nAbilityEntityIndex ) -
- GetAssociatedPrimaryAbilities( nAbilityEntityIndex ) -
- GetAssociatedSecondaryAbilities( nAbilityEntityIndex ) -
- GetHotkeyOverride( nAbilityEntityIndex ) -
- GetIntrinsicModifierName( nAbilityEntityIndex ) -
- GetSharedCooldownName( nAbilityEntityIndex ) -
- AbilityReady( nAbilityEntityIndex ) -
- CanAbilityBeUpgraded( nAbilityEntityIndex ) -
- CanBeExecuted( nAbilityEntityIndex ) -
- GetAbilityDamage( nAbilityEntityIndex ) -
- GetAbilityDamageType( nAbilityEntityIndex ) -
- GetAbilityTargetFlags( nAbilityEntityIndex ) -
- GetAbilityTargetTeam( nAbilityEntityIndex ) -
- GetAbilityTargetType( nAbilityEntityIndex ) -
- GetAbilityType( nAbilityEntityIndex ) -
- GetBehavior( nAbilityEntityIndex ) -
- GetCastRange( nAbilityEntityIndex ) -
- GetChannelledManaCostPerSecond( nAbilityEntityIndex ) -
- GetCurrentCharges( nAbilityEntityIndex ) -
- GetEffectiveLevel( nAbilityEntityIndex ) -
- GetHeroLevelRequiredToUpgrade( nAbilityEntityIndex ) -
- GetLevel( nAbilityEntityIndex ) -
- GetManaCost( nAbilityEntityIndex ) -
- GetMaxLevel( nAbilityEntityIndex ) -
- AttemptToUpgrade( nAbilityEntityIndex ) -
- CanLearn( nAbilityEntityIndex ) -
- GetAutoCastState( nAbilityEntityIndex ) -
- GetToggleState( nAbilityEntityIndex ) -
- HasScepterUpgradeTooltip( nAbilityEntityIndex ) -
- IsActivated( nAbilityEntityIndex ) -
- IsActivatedChanging( nAbilityEntityIndex ) -
- IsAttributeBonus( nAbilityEntityIndex ) -
- IsAutocast( nAbilityEntityIndex ) -
- IsCooldownReady( nAbilityEntityIndex ) -
- IsCosmetic( nAbilityEntityIndex ) -
- IsHidden( nAbilityEntityIndex ) -
- IsHiddenWhenStolen( nAbilityEntityIndex ) -
- IsInAbilityPhase( nAbilityEntityIndex ) -
- IsItem( nAbilityEntityIndex ) -
- IsMarkedAsDirty( nAbilityEntityIndex ) -
- IsMuted( nAbilityEntityIndex ) -
- IsOnCastbar( nAbilityEntityIndex ) -
- IsOnLearnbar( nAbilityEntityIndex ) -
- IsOwnersGoldEnough( nAbilityEntityIndex ) -
- IsOwnersGoldEnoughForUpgrade( nAbilityEntityIndex ) -
- IsOwnersManaEnough( nAbilityEntityIndex ) -
- IsPassive( nAbilityEntityIndex ) -
- IsRecipe( nAbilityEntityIndex ) -
- IsSharedWithTeammates( nAbilityEntityIndex ) -
- IsStealable( nAbilityEntityIndex ) -
- IsStolen( nAbilityEntityIndex ) -
- GetAOERadius( nAbilityEntityIndex ) -
- GetBackswingTime( nAbilityEntityIndex ) -
- GetCastPoint( nAbilityEntityIndex ) -
- GetChannelStartTime( nAbilityEntityIndex ) -
- GetChannelTime( nAbilityEntityIndex ) -
- GetCooldown( nAbilityEntityIndex ) -
- GetCooldownLength( nAbilityEntityIndex ) -
- GetCooldownTime( nAbilityEntityIndex ) -
- GetCooldownTimeRemaining( nAbilityEntityIndex ) -
- GetDuration( nAbilityEntityIndex ) -
- GetUpgradeBlend( nAbilityEntityIndex ) -
- GetCaster( nAbilityEntityIndex ) -
- GetCustomValueFor( nAbilityEntityIndex ) -
- GetSpecialValueFor( nAbilityEntityIndex, name ) -
- GetLevelSpecialValueFor( nAbilityEntityIndex, name, level ) -
Item
Given an item entity index (returned from npc.GetItemInSlot), these functions return information about the item.
globals.Items.
- AlwaysDisplayCharges( nItemEntityIndex ) -
- CanBeSoldByLocalPlayer( nItemEntityIndex ) -
- CanDoubleTapCast( nItemEntityIndex ) -
- ForceHideCharges( nItemEntityIndex ) -
- IsAlertableItem( nItemEntityIndex ) -
- IsCastOnPickup( nItemEntityIndex ) -
- IsDisassemblable( nItemEntityIndex ) -
- IsDroppable( nItemEntityIndex ) -
- IsInnatelyDisassemblable( nItemEntityIndex ) -
- IsKillable( nItemEntityIndex ) -
- IsMuted( nItemEntityIndex ) -
- IsPermanent( nItemEntityIndex ) -
- IsPurchasable( nItemEntityIndex ) -
- IsRecipe( nItemEntityIndex ) -
- IsRecipeGenerated( nItemEntityIndex ) -
- IsSellable( nItemEntityIndex ) -
- IsStackable( nItemEntityIndex ) -
- ProRatesChargesWhenSelling( nItemEntityIndex ) -
- RequiresCharges( nItemEntityIndex ) -
- CanBeExecuted( nItemEntityIndex ) -
- GetCost( nItemEntityIndex ) -
- GetCurrentCharges( nItemEntityIndex ) -
- GetDisplayedCharges( nItemEntityIndex ) -
- GetInitialCharges( nItemEntityIndex ) -
- GetItemColor( nItemEntityIndex ) -
- GetShareability( nItemEntityIndex ) -
- GetAbilityTextureSF( nItemEntityIndex ) -
- GetAssembledTime( nItemEntityIndex ) -
- GetPurchaseTime( nItemEntityIndex ) -
- GetPurchaser( nItemEntityIndex ) -
Misc
- gameAPI.SubscribeToGameEvent( "event", callbackFunction )
- gameAPI.SendServerCommand( "consolecommand" ) - send a console command to the server. This can be a console command registered in your server side game mode .lua (see Convars:RegisterCommand in holdout_example/scripts/vscripts/addon_game_mode.lua for an example)
- globals.GameInterface.PlaySound( "soundname" ) - play a sound effect. NOTE: Custom game sounds are currently not supported.
- globals.GameInterface.StopSound( "soundname" )
- globals.GameInterface.AddKeyInputConsumer() - if you call this, the UI will start to eat all keypresses and will receive key input events. It's very important to call RemoveKeyInputConsumer when your UI is done processing input.
- globals.GameInterface.RemoveKeyInputConsumer() - this must be called once for every call of AddKeyInputConsumer for key input to return to the game.