#I'm trying to make the jungle creeps join a team a few seconds after spawning then follow a path

1 messages · Page 1 of 1 (latest)

sullen marsh
#

this is the version that works on npc_dota_neutral_spawner , it converts the creeps but can't dissable the netural creep behavior and make them follow a path

#

JungleConverter = JungleConverter or class({})

function JungleConverter:Init()
print("===== NEUTRAL AI PURGE SYSTEM =====")

-- Configuration
self.spawnerName = "jungle_spawner1"
self.waypointName = "lane_mid_pathcorner_goodguys_1"
self.conversionDelay = 3.0

-- Get waypoint
self.waypoint = Entities:FindByName(nil, self.waypointName)
if not self.waypoint then
    print("ERROR: Waypoint missing!")
    return
end
self.waypointPos = self.waypoint:GetAbsOrigin()

-- Find spawner
local allSpawners = Entities:FindAllByClassname("npc_dota_neutral_spawner")
for _,spawner in pairs(allSpawners) do
    if spawner:GetName() == self.spawnerName then
        self.spawnPos = spawner:GetAbsOrigin()
        break
    end
end

if not self.spawnPos then
    print("ERROR: Spawner missing!")
    return
end

-- Start the scanner
self:StartNeutralPurgeScanner()

end

function JungleConverter:StartNeutralPurgeScanner()
GameRules:GetGameModeEntity():SetContextThink("NeutralPurgeScanner",
function()
self:ScanAndPurgeNeutralAI()
return 0.2
end,
0)
end

function JungleConverter:ScanAndPurgeNeutralAI()
local creeps = FindUnitsInRadius(
DOTA_TEAM_NEUTRALS,
self.spawnPos,
nil,
400,
DOTA_UNIT_TARGET_TEAM_FRIENDLY,
DOTA_UNIT_TARGET_BASIC,
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_ANY_ORDER,
false
)

local gameTime = GameRules:GetGameTime()

for _,creep in pairs(creeps) do
    if not creep.conversionTime then
        creep.conversionTime = gameTime + self.conversionDelay
    end
    
    if creep.conversionTime and gameTime >= creep.conversionTime and not creep.converted then
        self:CompleteNeutralPurge(creep)
    end
end

end

#

function JungleConverter:CompleteNeutralPurge(creep)
if not IsValidEntity(creep) then return end

creep:SetTeam(DOTA_TEAM_GOODGUYS)
creep:SetOwner(nil)

-- 2. COMPLETE MODIFIER PURGE
for i=0,15 do
    local modifier = creep:GetModifierNameByIndex(i)
    if modifier then
        creep:RemoveModifierByName(modifier)
    end
end

-- 3. NEUTRAL AI CORE DISABLE
creep:SetContext("disable_neutral_ai", "1", 0)
creep:SetThink("NeutralReturnThinker", function() return nil end) -- Kill return thinker
creep:SetMustReachEachGoalEntity(true)

-- 4. MOVEMENT SYSTEM RESET
creep:SetBaseMoveSpeed(325)
creep:SetIdleAcquire(false)
creep:SetAcquisitionRange(0)
creep:Stop()
creep:Interrupt()

-- 5. PATHING SETUP
creep:SetInitialGoalEntity(self.waypoint)

for i=1,5 do
    GameRules:GetGameModeEntity():SetContextThink(DoUniqueString("MoveCommand"..i),
        function()
            if IsValidEntity(creep) then
                ExecuteOrderFromTable({
                    UnitIndex = creep:entindex(),
                    OrderType = DOTA_UNIT_ORDER_MOVE_TO_POSITION,
                    Position = self.waypointPos,
                    Queue = false
                })
            end
        end,
    0.1 * i)
end

ParticleManager:CreateParticle("particles/items_fx/diffusal_slow.vpcf", PATTACH_ABSORIGIN_FOLLOW, creep)
DebugDrawCircle(self.waypointPos, Vector(0,255,0), 100, 25, true, 30)

creep.converted = true
print("NEUTRAL AI PURGE COMPLETE: "..creep:GetUnitName())

end

#

.

#

.

#

.

#

.