Dota 2 Workshop Tools/Scripting/API/CDOTA BaseNPC Hero.AddExperience
From Valve Developer Community
< Dota 2 Workshop Tools | Scripting | API

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