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

From Valve Developer Community
Jump to navigation Jump to search
Note.pngNote: This page is automatically generated. Any changes may be overwritten

Function Description

bool AddExperience(float amount, bool applyBotDifficultyScaling, bool addXPToPlayerResource)

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,true)
        level = spawnedUnit:GetLevel()
      end
  end
end

Parameters

Type Name Description
float amount No Description Set
bool applyBotDifficultyScaling No Description Set
bool addXPToPlayerResource Controls whether the added experience is tallied into the PlayerResource

Returns

bool - No Description Set