Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. function SpawnUnitKilled (event)
  2. local victim = EntIndexToHScript( event.entindex_killed )
  3. if victim:GetUnitName() == "Ancient Guardian" then
  4. GameRules:SetGameWinner(DOTA_TEAM_BADGUYS)
  5. end
  6. if victim:IsCreature() and victim:GetTeam() == DOTA_TEAM_BADGUYS and event.entindex_attacker ~= nil then
  7. remains = remains - 1
  8. local result={ remains = remains }
  9. CustomGameEventManager:Send_ServerToTeam( DOTA_TEAM_GOODGUYS, "NPC_Wave_Remains", result)
  10. local Drop_Info = GameRules.DropTable[victim:GetUnitName()]
  11. dropitem(Drop_Info, victim)
  12. end
  13. if victim:IsCreature() and victim:GetTeam() == DOTA_TEAM_NEUTRALS then
  14. local Drop_Info = GameRules.DropTable[victim:GetUnitName()]
  15. dropitem(Drop_Info, victim)
  16. end
  17. if victim:IsCreature() and victim:GetTeam() == DOTA_TEAM_BADGUYS and event.entindex_attacker ~= nil then
  18. remains = remains - 1
  19. local result={ remains = remains }
  20. CustomGameEventManager:Send_ServerToTeam( DOTA_TEAM_GOODGUYS, "NPC_Wave_Remains", result)
  21. local Drop_Info = GameRules.DropTable[victim:GetUnitName()]
  22. dropitem2(Drop_Info, victim)
  23. end
  24. if victim:IsCreature() and victim:GetTeam() == DOTA_TEAM_NEUTRALS then
  25. local Drop_Info = GameRules.DropTable[victim:GetUnitName()]
  26. dropitem2(Drop_Info, victim)
  27. end
  28. end
  29.  
  30.  
  31. function dropitem(Drop_Info, victim)
  32. if Drop_Info then
  33. for item_name, chance in pairs(Drop_Info) do
  34. if RollPercentage(chance) then
  35. local item = CreateItem(item_name, nil, nil)
  36. local pos = victim:GetAbsOrigin()
  37. if item_name == "item_bag_of_gold" then
  38. item:SetCurrentCharges(RandomInt(75,150))
  39. end
  40. local landed = pos + RandomVector(RandomFloat(-220,220))
  41. local drop = CreateItemOnPositionSync(pos, item)
  42. if victim:GetTeam() == DOTA_TEAM_BADGUYS then
  43. item:LaunchLoot(true, 400, 0.7, landed)
  44. else
  45. item:LaunchLoot(false, 400, 0.7, landed)
  46. end
  47. Timers:CreateTimer(15, function()
  48. clearitem(item)
  49. end)
  50. end
  51. end
  52. end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement