Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. SPAWNLOCATION = "path_customspawn"
  2. WAYPOINTNAME = "path_test_1"
  3.  
  4. if customSpawn == nil then
  5.         customSpawn = class({})
  6. end
  7.  
  8. function Precache( context )
  9.         --Cache the Gnoll Assassin model
  10.         PrecacheUnitByNameSync( "npc_dota_npc_base", context )
  11.         PrecacheModel( "npc_dota_npc_base", context )
  12. end
  13.  
  14. function customSpawn:spawnunits()
  15.  
  16.         local spawnLocation = Entities:FindByName( nil, SPAWNLOCATION )
  17.         local waypointlocation = Entities:FindByName ( nil, WAYPOINTNAME)
  18.         local creature = CreateUnitByName( "npc_dota_npc_base" , spawnLocation:GetAbsOrigin() + RandomVector( RandomFloat( 0, 200 ) ), true, nil, nil, DOTA_TEAM_NEUTRALS )
  19.                 print ("create unit has run")
  20.                 creature:SetInitialGoalEntity( waypointlocation )
  21.  
  22.  
  23. end    
  24.  
  25. function Activate()
  26.  
  27.                 GameRules.customSpawn = customSpawn()
  28.                 GameRules.customSpawn:InitGameMode()
  29.                 --thisEntity:SetContextThink("customSpawn:spawnunits", spawnunits, 5)
  30.  
  31.  
  32. end
  33.  
  34. function customSpawn:InitGameMode()
  35.                 self.spawnunits()
  36.                 ListenToGameEvent("entity_killed", Dynamic_Wrap(customSpawn, 'ourcreepskilled'), self)
  37.                 print ("Listen To GameEvent Fired Entity Got Killed Now")
  38.                
  39. end
  40.  
  41. function customSpawn:ourcreepskilled( keys )
  42.         local unit = EntIndexToHScript( keys.entindex_killed )
  43.         if string.find(unit:GetUnitName(),"npc_dota_npc_base") then
  44.         print ("We found NPC_DoTA_NPC_BASE GOT KILLED LETS CALL SPAWNUNITS FUNCTION")
  45.         return customSpawn:spawnunits()
  46.         end    
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement