4ªU`luascripts/vscriptsl4d2_improvedbotssðp�ÿíÙ ÿÿtxt addoninfoš eÍÿíÿÿ"AddonInfo" { "AddonName" "L4D2 Improved bots" "Addontitle" "L4D2 Improved bots" "AddonDescription" "Enhances the behavior of AI bots in Left 4 Dead 2." "AddonVersion" "1.5" "AddonAuthor" "Mark" } -- Improved AI Script with Dynamic Tank Avoidance, Customizable Parameters, and Reaction Time for Left 4 Dead 2 -- Configuration Settings local config = { shoveRange = 150, -- Range for auto-shoving infected dodgeChargerRange = 800, -- Range for dodging Charger bashFlyingRange = 200, -- Range for bashing flying infected shootRange = 7500, -- Range for shooting special infected takeCoverRange = 500, -- Range for taking cover from tank rocks dynamicAvoidanceRange = 800, -- Range for dynamically avoiding the tank reviveCancelRange = 300, -- Range for canceling revives when tank is approaching avoidFireSpitRange = 300, -- Range for avoiding fire and spit reactionTime = 0.1, -- Reaction time in seconds avoidDynamicPropRange = 500, -- Range for avoiding dynamic props when the tank is nearby dodgeDynamicPropSize = 350, -- Size of dynamic props to trigger dodging } -- Function to make bots avoid dynamic props when the tank is nearby function AvoidDynamicProps(bot, tank) local dynamicProps = Entities:FindAllByClassnameWithin("prop_physics", bot:GetAbsOrigin(), config.avoidDynamicPropRange) for _, prop in ipairs(dynamicProps) do if IsValidEntity(prop) and prop:GetModelName() ~= "" then local distanceToProp = bot:GetRangeTo(prop) local distanceToTank = bot:GetRangeTo(tank) if distanceToProp < config.avoidDynamicPropRange and distanceToTank < config.dynamicAvoidanceRange then bot:MoveAwayFromPosition(prop:GetAbsOrigin()) end end end end -- Function to dodge flying dynamic props based on their size function DodgeFlyingDynamicProps(bot, prop) if prop:GetBoundingMaxs().z - prop:GetBoundingMins().z > config.dodgeDynamicPropSize then bot:MoveAwayFromPosition(prop:GetAbsOrigin()) end end -- Function to handle dynamic tank avoidance function DynamicTankAvoidance(bot, tank) local tankPosition = tank:GetAbsOrigin() local avoidancePosition = bot:GetAbsOrigin() + RandomVector(config.dynamicAvoidanceRange) bot:MoveAwayFromPosition(avoidancePosition) end -- Function to handle tank avoidance with configurable parameters function TankAvoidance(bot, tank) local isTankCharging = tank:IsCharging() if isTankCharging then AvoidDynamicProps(bot, tank) DynamicTankAvoidance(bot, tank) end end -- Main function to handle AI behavior with configurable parameters function ImprovedAIBehavior(bot) local nearbySpecialInfected = bot:GetNearbySpecialInfected() local charger = bot:GetCharger() local tank = bot:GetTank() AutoShoveInfected(bot) AvoidFireAndSpit(bot) for _, infected in ipairs(nearbySpecialInfected) do ShootSpecialInfected(bot, infected) BashFlyingInfected(bot, infected) end if charger then DelayedAction(DodgeCharger, config.reactionTime)(bot, charger) DelayedAction(ShootSpecialInfected, config.reactionTime)(bot, charger) end if tank then TankAvoidance(bot, tank) StopReviveWhenTankIsApproaching(bot, tank) ShootTankRock(bot, tank:GetRock()) end end -- Hook into the AI system to apply improved behavior with configurable parameters AddThinkFunction(function() local bots = GetBots() for _, bot in ipairs(bots) do ImprovedAIBehavior(bot) end end)