--Made by wacev --idc if you copy this for any purpose, just credit me InLoseState = false CurrentWave = ents.FindByClass('tf_objective_resource').m_nMannVsMachineWaveCount Difficulty = 1 function GiveMoney(robot) local MoneyMult local MoneyAmount if robot.m_bIsMiniBoss == 1 then MoneyMult = 5 else MoneyMult = 1 end if CurrentWave <= 8 then MoneyMult = MoneyMult * 2 end MoneyAmount = math.floor( robot.MaxHealth * 0.01 ) -- basic with 100 hp gives 1 cash on kill MoneyAmount = MoneyAmount * MoneyMult if MoneyAmount < 1 then MoneyAmount = 1 end if InLoseState == false then --important, without this enemies killed via lose explosion, or just after defeat, will increase credit amount. This could be abused to make infinite money for _, player in pairs(ents.GetAllPlayers()) do if player:IsRealPlayer() then player:AddCurrency(MoneyAmount) end end for _, stats in pairs(ents.FindAllByClass("tf_mann_vs_machine_stats")) do stats.nCreditsAcquired = stats.nCreditsAcquired + MoneyAmount stats.nCreditsBonus = stats.nCreditsBonus - MoneyAmount end end end function SetDifficulty(MissionNameString) if string.match(MissionNameString, "normal") then return 1 elseif string.match(MissionNameString, "intermediate") then return 1.25 elseif string.match(MissionNameString, "advanced") then return 1.5 elseif string.match(MissionNameString, "expert") then return 2 else print("Invalid mission name; mission name doesn't have an assigned difficulty") print("Please add: 'normal', 'intermediate', 'advanced', or 'expert' to the popfile name; or change it in a point template") print("Mission difficulty has been set to normal") util.PrintToChatAll("Invalid mission name; mission name doesn't have an assigned difficulty") util.PrintToChatAll("Please add: 'normal', 'intermediate', 'advanced', or 'expert' to the popfile name; or change it in a point template") util.PrintToChatAll("Mission difficulty has been set to normal") return 1 end end function OnWaveInit() InLoseState = false CurrentWave = ents.FindByClass('tf_objective_resource').m_nMannVsMachineWaveCount timer.Simple(0.5,function() local MissionName = ents.FindByClass('tf_objective_resource').m_iszMvMPopfileName Difficulty = SetDifficulty(MissionName) ents.FindByName("capturezone_blue"):AddCallback(ON_START_TOUCH, function(_, player) if player.m_iTeamNum == 3 then InLoseState = true end end) end) end function OnWaveSpawnBot(bot, wave, tags) timer.Simple(0.01, function() bot.MaxHealth = bot.m_iHealth end) timer.Simple(0.02, function() bot:SetAttributeValue("mult max health", Difficulty) end) end function OnPlayerConnected(player) if player:IsBot() then player:AddCallback(ON_DEATH, function() GiveMoney(player) end) end end