Advertisement
epitaque_

Untitled

Jun 27th, 2015
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. --This function isn't moving the hero like it should
  2. --Also when getting the heroes' location, its returning 0, 0, 0
  3. --How do I get npc to equal the actual hero being spawned?
  4.  
  5. function GameMode:OnNPCSpawned(keys)
  6.   DebugPrint("[BAREBONES] NPC Spawned")
  7.   DebugPrintTable(keys)
  8.  
  9.   -- This internal handling is used to set up main barebones functions
  10.   GameMode:_OnNPCSpawned(keys)
  11.  
  12.   local npc = EntIndexToHScript(keys.entindex)
  13.  
  14.   if npc.IsRealHero and npc:IsRealHero() then
  15.     local ents = Entities:FindAllByName("spawnpoint")
  16.     DebugPrint("[STICKARENA] finding all entities by name spawnpoint")
  17.     DebugPrintTable(ents)
  18.  
  19.     --get amount of entities because lua is stupid
  20.     local Count = 0
  21.  
  22.     for Index, Value in pairs( ents ) do
  23.       Count = Count + 1
  24.       print('[STICKARENA] entity count: ', Count)
  25.     end
  26.  
  27.  
  28.     if Count > 0 then
  29.       local infotarget = ents[RandomInt(1, Count)]
  30.       print('[STICKARENA] Getting random spawnpoint entity: ', infotarget)
  31.       print('[STICKARENA] The vector position of that entity is: ', infotarget:GetAbsOrigin()) --Returns a valid vector
  32.       print('[STICKARENA] The vector position of the hero is: ', npc:GetAbsOrigin()) --Is 0, 0, 0 for some reason when that's not where the hero is at all
  33.       npc:SetAbsOrigin(infotarget:GetAbsOrigin()) --Doesn't do anything
  34.     else
  35.       print('[STICKARENA] ERROR: no spawnpoint entities')
  36.     end
  37.   end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement