Advertisement
dr4kedecep

ZombieArena.lua

Dec 6th, 2015
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.71 KB | None | 0 0
  1.  print ('[ZOMBIEARENA] ZombieArena.lua')
  2.  
  3.  
  4. DISABLE_FOG_OF_WAR_ENTIRELY = false
  5. UNSEEN_FOG_ENABLED = false
  6.  
  7.  
  8. XP_PER_LEVEL_TABLE = {
  9.     0, -- 1
  10.     100, -- 2
  11.     200, -- 3
  12.     300, -- 4
  13.     400, -- 5
  14.     500, -- 6
  15.     600, -- 7
  16.     700, -- 8
  17.     800, -- 9
  18.     900, -- 10
  19.     1000,   -- 11
  20.     1500,   -- 12
  21.     2000,   -- 13
  22.     2500,   -- 14
  23.     3000,   -- 15
  24.     3500,   -- 16
  25.     4000,   -- 17
  26.     4500,   -- 18
  27.     5000,   -- 19
  28.     6000,   -- 20
  29.     7000,   -- 21
  30.     8000,   -- 22
  31.     9000,   -- 23
  32.     10000,  -- 24
  33.     15000,  -- 25
  34.     20000,  -- 26
  35.     25000,  -- 27
  36.     30000,  -- 28
  37.     35000,  -- 29
  38.     40000,  -- 30
  39.     45000,  -- 31
  40.     50000,  -- 32
  41.     55000,  -- 33
  42.     60000,  -- 34
  43.     65000,  -- 35
  44.     70000,  -- 36
  45.     75000,  -- 37
  46.     80000,  -- 38
  47.     85000,  -- 39
  48.     90000,  -- 40
  49.     95000,  -- 41
  50.     100000, -- 42
  51.     110000, -- 43
  52.     120000, -- 44
  53.     130000, -- 45
  54.     140000, -- 46
  55.     150000, -- 47
  56.     160000, -- 48
  57.     170000, -- 49
  58.     200000, -- 50
  59.  }
  60.  
  61.  
  62.  
  63. function ZombieArena:InitGameMode()
  64.     print( "[ZOMBIEARENA] Loading gamemode..." )
  65.  
  66.         -- Setup rules
  67.         GameRules:SetHeroRespawnEnabled( true )
  68.         GameRules:SetUseUniversalShopMode( false )
  69.         GameRules:SetSameHeroSelectionEnabled( true )
  70.         GameRules:SetHeroSelectionTime( 0 )
  71.         GameRules:SetPreGameTime( 30 )
  72.         GameRules:SetPostGameTime( 0 )
  73.         GameRules:SetTreeRegrowTime( 1000.0 )
  74.         GameRules:SetUseCustomHeroXPValues ( true )
  75.         GameRules:SetGoldPerTick(0)
  76.         GameRules:SetUseBaseGoldBountyOnHeroes( false ) -- Need to check legacy values
  77.         GameRules:SetHeroMinimapIconScale( 1 )
  78.         GameRules:SetCreepMinimapIconScale( 1 )
  79.         GameRules:SetRuneMinimapIconScale( 1 )
  80.         GameRules:SetFirstBloodActive( false )
  81.         GameRules:SetHideKillMessageHeaders( true )
  82.         GameRules:EnableCustomGameSetupAutoLaunch( false )
  83.  
  84.         -- Set game mode rules
  85.         GameMode = GameRules:GetGameModeEntity()        
  86.         GameMode:SetRecommendedItemsDisabled( true )
  87.         GameMode:SetBuybackEnabled( false )
  88.         GameMode:SetTopBarTeamValuesOverride ( true )
  89.         GameMode:SetTopBarTeamValuesVisible( true )
  90.         GameMode:SetUseCustomHeroLevels ( true )
  91.         GameMode:SetUnseenFogOfWarEnabled( UNSEEN_FOG_ENABLED )
  92.         GameMode:SetTowerBackdoorProtectionEnabled( false )
  93.         GameMode:SetGoldSoundDisabled( true )
  94.         GameMode:SetRemoveIllusionsOnDeath( true )
  95.         GameMode:SetAnnouncerDisabled( true )
  96.         GameMode:SetLoseGoldOnDeath( false )
  97.         GameMode:SetCustomXPRequiredToReachNextLevel( XP_PER_LEVEL_TABLE )
  98.         GameMode:SetFogOfWarDisabled( DISABLE_FOG_OF_WAR_ENTIRELY )
  99.         GameMode:SetCustomHeroMaxLevel ( 50 )
  100.  
  101.         -- Team Configuartion
  102.         if GetMapName() == "zombiejungle_map1" then
  103.             GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_GOODGUYS,  5 )
  104.             GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_BADGUYS,   -1 )
  105.         end
  106.  
  107.  
  108.     -- Event Hooks
  109.     ListenToGameEvent('player_connect_full', Dynamic_Wrap(ZombieArena, 'OnConnectFull'), self)
  110.     ListenToGameEvent('npc_spawned', Dynamic_Wrap(ZombieArena, 'OnNPCSpawned'), self)
  111.     ListenToGameEvent('dota_player_pick_hero', Dynamic_Wrap(ZombieArena, 'OnPlayerPickHero'), self)
  112.     ListenToGameEvent('game_rules_state_change', Dynamic_Wrap(ZombieArena, 'BeginWaves'), self)
  113.  
  114.  
  115.  
  116.     -- Full units file to get the custom values
  117.     GameRules.AbilityKV = LoadKeyValues("scripts/npc/npc_abilities_custom.txt")
  118.     GameRules.UnitKV = LoadKeyValues("scripts/npc/npc_units_custom.txt")
  119.     GameRules.HeroKV = LoadKeyValues("scripts/npc/npc_heroes_custom.txt")
  120.     GameRules.ItemKV = LoadKeyValues("scripts/npc/npc_items_custom.txt")
  121.  
  122.     print( "[ZOMBIEARENA] Loading gamemode completed!")
  123. end
  124.  
  125.  
  126.  
  127. function ZombieArena:OnConnectFull(keys)
  128.     print ('[ZOMBIEARENA] OnConnectFull')
  129. end
  130.  
  131. function ZombieArena:OnFirstPlayerLoaded()
  132.     print("[ZOMBIEARENA] First Player has loaded")
  133. end
  134.  
  135. function ZombieArena:OnAllPlayersLoaded()
  136.     print("[ZOMBIEARENA] All Players have loaded into the game")
  137. end
  138.  
  139. function ZombieArena:OnHeroInGame( hero )
  140.     local hero_name = hero:GetUnitName()
  141.     print("[ZOMBIEARENA] OnHeroInGame "..hero_name)
  142.  
  143.     Attributes:ModifyBonuses(hero)
  144. end
  145.  
  146. function ZombieArena:InitializePlayer( hero )
  147.     local player = hero:GetPlayerOwner()
  148.     local playerID = hero:GetPlayerID()
  149.  
  150.     print("[ZOMBIEARENA] Initializing main hero entity for player "..playerID)
  151.  
  152.     Players:Init(playerID, hero)
  153. end
  154.  
  155.  
  156. -- An NPC has spawned somewhere in game.  This includes heroes
  157. function ZombieArena:OnNPCSpawned(keys)
  158.     --print("[DOTACRAFT] NPC Spawned")
  159.     --DeepPrintTable(keys)
  160.     local npc = EntIndexToHScript(keys.entindex)
  161.  
  162.     if npc:IsHero() then
  163.         npc.strBonus = 0
  164.         npc.intBonus = 0
  165.         npc.agilityBonus = 0
  166.         npc.attackspeedBonus = 0
  167.     end
  168.  
  169.     if npc:IsRealHero() and npc.bFirstSpawned == nil then
  170.         npc.bFirstSpawned = true
  171.         ZombieArena:OnHeroInGame(npc)
  172.     end
  173. end
  174.  
  175. -- A player picked a hero
  176. function ZombieArena:OnPlayerPickHero(keys)
  177.     print ('[ZOMBIEARENA] OnPlayerPickHero')
  178.     local hero = EntIndexToHScript(keys.heroindex)
  179.     local player = EntIndexToHScript(keys.player)
  180.     local playerID = hero:GetPlayerID()
  181.    
  182.     -- Remove invulnerability from GoldenIdol
  183.     local GoldenIdol = Entities:FindByName(nil, "building_gold_idol")
  184.     GoldenIdol:SetControllableByPlayer(playerID, false)
  185.     GoldenIdol:RemoveModifierByName("modifier_invulnerable")
  186.    
  187. end
  188.  
  189. function ZombieArena:BeginWaves( keys )
  190.     print(GameRules:State_Get())
  191.  
  192.     if GameRules:State_Get() == 7 then
  193.        
  194.     local ZombieTower_high = Entities:FindByName(nil, "npc_zombie_spawner1")
  195.     local ZombieTower_low = Entities:FindByName(nil, "npc_zombie_spawner2")
  196.     local ZTh_location = ZombieTower_high:GetAbsOrigin()
  197.     local ZTl_location = ZombieTower_low:GetAbsOrigin()
  198.     local waitingForNextRound = 1
  199.  
  200.  
  201.         for round_num = 1,3     do
  202.  
  203.             local messageinfo_round = {
  204.             message = 'Round '..round_num,
  205.             dur = 5000,
  206.             bool = true
  207.             }
  208.  
  209.             FireGameEvent("show_center_message", messageinfo_round)
  210.  
  211.             --spawn a generic zombie
  212.             if round_num == 1 then
  213.  
  214.                 local ZombieTower_high = CreateUnitByName("Undead Warrior", ZTh_location, true, hero, hero, DOTA_TEAM_BADGUYS)
  215.  
  216.             else if round_num == 2 then
  217.  
  218.                 local ZombieTower_low = CreateUnitByName("Strong Warrior", ZTl_location, true, hero, hero, DOTA_TEAM_BADGUYS)
  219.            
  220.             else if round_num == 3 then
  221.  
  222.                 local ZombieTower_high = CreateUnitByName("Undead Warrior", ZTh_location, true, hero, hero, DOTA_TEAM_BADGUYS)
  223.                 local ZombieTower_low = CreateUnitByName("Strong Warrior", ZTl_location, true, hero, hero, DOTA_TEAM_BADGUYS)
  224.             end
  225.            
  226.             while waitingForNextRound == 1
  227.                 do
  228.                 local remaining_undead = Entities:FindAllByName('Undead Warrior')
  229.                 local remaining_strong = Entities:FindAllByName('Strong Warrior')
  230.                 local remaining_nzombies = table.getn(remaining_undead) + table.getn(remaining_strong)
  231.  
  232.                 print('Remaining Zombies: '..remaining_nzombies)
  233.  
  234.                 if remaining_nzombies == 0 then
  235.                    
  236.                     print('Next Round: '..round_num + 1)
  237.                     break end
  238.                 end
  239.             end
  240.         end
  241.     end
  242. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement