Dota 2 Workshop Tools/Scripting/API/CDOTA BaseNPC Hero.AddExperience

From Valve Developer Community
Jump to: navigation, search
Dead End - Icon.png
This article has no links to other VDC articles. Please help improve this article by adding links that are relevant to the context within the existing text.
January 2024
Note.pngNote: This page is automatically generated. Any changes may be overwritten

Function Description

bool AddExperience(float amount, int nReason, bool bApplyBotDifficultyScaling, bool bIncrementTotal)

Adds experience to this unit.

Example
--Upgrade any spawned hero to Level 6
function MyGameMode:OnNPCSpawned( keys )
  local spawnedUnit = EntIndexToHScript( keys.entindex )
  if spawnedUnit:IsHero() then
    local level = spawnedUnit:GetLevel()
      while level < 6 do
        spawnedUnit:AddExperience (2000,false)
        level = spawnedUnit:GetLevel()
      end
  end
end

Parameters

Type Name Description
float amount No Description Set
int nReason No Description Set
bool bApplyBotDifficultyScaling No Description Set
bool bIncrementTotal No Description Set

Returns

bool - No Description Set