I am trying to adjust the gold received in a custom map from a creep. However, it is not halfing at all.
---redacted ---
-- Event handler for entity killed
function YourGameMode:OnEntityKilled(keys)
local killedUnit = EntIndexToHScript(keys.entindex_killed)
local killerEntity = nil
if keys.entindex_attacker ~= nil then
killerEntity = EntIndexToHScript(keys.entindex_attacker)
end
-- Check if the killed unit is a creep and the killer is a hero
if killedUnit and killerEntity and killedUnit:IsCreep() and killerEntity:IsHero() then
-- Get the original bounty
local originalBounty = killedUnit:GetGoldBounty()
-- Set to 50% of the original bounty
local modifiedBounty = math.floor(originalBounty * 0.5)
-- Remove the original gold that would be given automatically
killerEntity:ModifyGold(-originalBounty, true, DOTA_ModifyGold_CreepKill)
-- Give the modified amount
killerEntity:ModifyGold(modifiedBounty, true, DOTA_ModifyGold_CreepKill)
-- Print debug information
print("Creep kill - setting gold to half: " .. modifiedBounty .. " (original: " .. originalBounty .. ")")
-- Optional: Display the modified gold amount
local player = killerEntity:GetPlayerOwner()
if player then
-- Create a floating gold text
local particleID = ParticleManager:CreateParticleForPlayer("particles/msg_fx/msg_gold.vpcf", PATTACH_OVERHEAD_FOLLOW, killerEntity, player)
ParticleManager:SetParticleControl(particleID, 1, Vector(0, modifiedBounty, 0))
ParticleManager:SetParticleControl(particleID, 2, Vector(1, math.floor(math.log10(modifiedBounty)) + 1, 0))
ParticleManager:SetParticleControl(particleID, 3, Vector(255, 200, 33))
end
end
end```