Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Script.Load("../ns2/lua/NS2Utility.lua")
- local kSentryBuildRadius = 21 //WARNING: don't set to large because it will limit sentry building in adjacent rooms.
- local kMaxSentryInArea = 4
- local _GetEntitiesWithClassname = Shared.GetEntitiesWithClassname
- //Noticed their wasn't a GetEntitiesWithinXZRange so i made one by stripping the team check from GetEntitiesForTeamWithinXZRange
- local function GetEntitiesWithinXZRange(className, origin, range)
- local rangeSquared = range * range
- local function inRangeXZFilterFunction(entity)
- local inRange = (entity:GetOrigin() - origin):GetLengthSquaredXZ() <= rangeSquared
- return inRange
- end
- return GetEntitiesWithFilter(_GetEntitiesWithClassname(className), inRangeXZFilterFunction)
- end
- local base_CheckBuildEntityRequirements = CheckBuildEntityRequirements
- local sentryClassName = "Sentry"
- local sentryErrorMessage = "Warning: Too many Sentries!"
- local _Count = table.count
- function CheckBuildEntityRequirements(techId, position, player, ignoreEntity)
- // Check if the entity is a Sentry
- if kTechId.Sentry == techId and _Count(GetEntitiesWithinXZRange(sentryClassName, position, kSentryBuildRadius)) >= kMaxSentryInArea then
- return false, sentryErrorMessage //legalBuild, errorString
- end
- return base_CheckBuildEntityRequirements(techId, position, player, ignoreEntity)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement