Issue with SetInitialGoalEntity() (Lua function)

edited November 14 in Questions

Does somebody knows what can I do if this doesn't work (this doesn't work with any neutral (which I tried) ) (custom_item.lua)


   local Waypoint = Entities:FindByName(nil,"woods_defolt_pathcorner_goodguys_snowcreeps_1")

   local callback = function (creature)
   creature:SetInitialGoalEntity(Waypoint)
   end

   local creature = CreateUnitByNameAsync( "npc_dota_neutral_ogre_mauler" ,self:GetCaster():GetOrigin(),true,nil,nil,self:GetCaster():GetTeamNumber(),callback)

--and this too

   local Waypoint = Entities:FindByName(nil,"woods_defolt_pathcorner_goodguys_snowcreeps_1")
   local creature = CreateUnitByName("npc_dota_neutral_ogre_mauler" ,self:GetCaster():GetOrigin(), true, nil, nil, self:GetCaster():GetTeamNumber())
   creature:SetInitialGoalEntity(Waypoint)

--and this

  local Waypoint = Entities:FindByName(nil,"woods_defolt_pathcorner_goodguys_snowcreeps_1")
  local creature = CreateUnitByName( "npc_dota_neutral_ogre_mauler" ,self:GetCaster():GetOrigin(), true, nil, nil, self:GetCaster():GetTeamNumber())
  order_type = DOTA_UNIT_ORDER_MOVE_TO_POSITION
  ExecuteOrderFromTable({ UnitIndex = creature:GetEntityIndex(), OrderType = order_type, Position = Waypoint:GetOrigin(), Queue = true})

--but this does work in any variations (the difference is only in "npc_dota_hero_windrunner" instead "npc_dota_neutral_ogre_mauler")

   local Waypoint = Entities:FindByName(nil,"woods_defolt_pathcorner_goodguys_snowcreeps_1")
   local creature = CreateUnitByName("npc_dota_hero_windrunner" ,self:GetCaster():GetOrigin(), true, nil, nil, self:GetCaster():GetTeamNumber())
   creature:SetInitialGoalEntity(Waypoint)

Comments

  • Posts: 271

    I think SetInitialGoalEntity doesn't work for neutral creeps. ExecuteOrderFromTable should work but ordering units should be delayed a bit after their creation. This should work:

    local destination_name = "woods_defolt_pathcorner_goodguys_snowcreeps_1"
    local units_to_spawn = "npc_dota_neutral_ogre_mauler"
    local number_of_units = 1
    local point = self:GetCaster():GetAbsOrigin()
    local waypoint = Entities:FindByName(nil, destination_name):GetAbsOrigin()
    local team = self:GetCaster():GetTeamNumber()
    for i=1,number_of_units do
       local unit = CreateUnitByName(units_to_spawn, point, true, nil, nil, team)
       Timers:CreateTimer(function()
          local order =
          {
             UnitIndex = unit:GetEntityIndex(),
             OrderType = DOTA_UNIT_ORDER_ATTACK_MOVE,
             Position = waypoint,
             Queue = true
          }
          ExecuteOrderFromTable(order)
       end)
    end
    

    If you don't use barebones timers library, you should.

  • Thank you

  • edited November 17 Posts: 3

    But I have same problem with your code (lazy ogre and normal wr), I tried to stop him for 2 sec (Timers:CreateTimer(2.0, function()...), but nothing