Skip to content

Commit

Permalink
Lock out enemy heroes from tier 1 bosses (#849)
Browse files Browse the repository at this point in the history
* Lock out enemy heroes from tier 1 bosses

* Give rewards to the team they belong to regardless of who gets the kill

* I dont listen to no chump ass indy rock
  • Loading branch information
chrisinajar authored May 24, 2017
1 parent 948e5c0 commit 4181001
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 6 deletions.
26 changes: 24 additions & 2 deletions game/scripts/vscripts/components/boss/ai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
if BossAI == nil then
DebugPrint ( 'creating new BossAI object' )
BossAI = class({})
BossAI.hasFarmingCore = {}
BossAI.hasReflexCore = {}

Debug.EnabledModules['boss:ai'] = false
end
Expand All @@ -26,6 +28,9 @@ function BossAI:Create (unit, options)
state = BossAI.IDLE,
customAgro = options.customAgro or false,

owner = options.owner,
isProtected = options.isProtected,

deathEvent = Event()
}

Expand Down Expand Up @@ -81,6 +86,9 @@ function BossAI:DeathHandler (state, keys)

state.deathEvent.broadcast(keys)

if state.isProtected then
teamId = state.owner
end
if teamId == 2 then
team = 'good'
elseif teamId == 3 then
Expand All @@ -93,23 +101,37 @@ function BossAI:DeathHandler (state, keys)

if state.tier == 1 then
BossAI:GiveItemToWholeTeam("item_upgrade_core", teamId)
local needsZoneDisable = false

if not BossAI.hasFarmingCore[team] then
BossAI.hasFarmingCore[team] = true
elseif not BossAI.hasReflexCore[team] then
BossAI.hasReflexCore[team] = true

BossSpawner[team .. "Zone1"].disable()
BossSpawner[team .. "Zone2"].disable()
end

for playerId = 0,19 do
if PlayerResource:GetTeam(playerId) == teamId and PlayerResource:GetPlayer(playerId) ~= nil then
local player = PlayerResource:GetPlayer(playerId)
local hero = player:GetAssignedHero()

if hero then
if not hero.hasFarmingCore then
if BossAI.hasFarmingCore[team] and not hero.hasFarmingCore then
hero:AddItemByName("item_farming_core")
hero.hasFarmingCore = true
elseif not hero.hasReflexCore then
elseif BossAI.hasReflexCore[team] and not hero.hasReflexCore then
hero:AddItemByName("item_reflex_core")
hero.hasReflexCore = true
end
end
end
end

if needsZoneDisable then
end

elseif state.tier == 2 then
NGP:GiveItemToTeam(BossItems["item_upgrade_core_2"], team)
NGP:GiveItemToTeam(BossItems["item_upgrade_core"], team)
Expand Down
57 changes: 53 additions & 4 deletions game/scripts/vscripts/components/boss/spawn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@ end

function BossSpawner:Init ()
Timers:CreateTimer(5, Dynamic_Wrap(BossSpawner, 'SpawnAllBosses'))

local allGoodPlayers = {}
local allBadPlayers = {}
local function addToList (list, id)
list[id] = true
end
each(partial(addToList, allGoodPlayers), PlayerResource:GetPlayerIDsForTeam(DOTA_TEAM_BADGUYS))
each(partial(addToList, allBadPlayers), PlayerResource:GetPlayerIDsForTeam(DOTA_TEAM_GOODGUYS))

BossSpawner.goodZone2 = ZoneControl:CreateZone('good_safe_pit_2', {
mode = ZONE_CONTROL_EXCLUSIVE_OUT,
margin = 300,
players = allGoodPlayers
})
BossSpawner.goodZone1 = ZoneControl:CreateZone('good_safe_pit_1', {
mode = ZONE_CONTROL_EXCLUSIVE_OUT,
margin = 300,
players = allGoodPlayers
})

BossSpawner.badZone2 = ZoneControl:CreateZone('bad_safe_pit_2', {
mode = ZONE_CONTROL_EXCLUSIVE_OUT,
margin = 300,
players = allBadPlayers
})
BossSpawner.badZone1 = ZoneControl:CreateZone('bad_safe_pit_1', {
mode = ZONE_CONTROL_EXCLUSIVE_OUT,
margin = 300,
players = allBadPlayers
})
end

function BossSpawner:SpawnAllBosses ()
Expand All @@ -32,14 +62,31 @@ function BossSpawner:SpawnBossAtPit (pit)
local tierIndex = math.min(#options, pit.killCount)
local bossTier = tierIndex - 1 + startTier
local bossName = options[tierIndex]
local isProtected = bossList == 1 and pit.killCount == 1

DebugPrint('Spawning ' .. bossName)
BossSpawner:SpawnBoss(pit, bossName, bossTier)
DebugPrint('Spawning ' .. bossName .. ' with protection ' .. tostring(isProtected))
BossSpawner:SpawnBoss(pit, bossName, bossTier, isProtected)
end

function BossSpawner:SpawnBoss (pit, boss, bossTier)
function BossSpawner:SpawnBoss (pit, boss, bossTier, isProtected)
local bossHandle = CreateUnitByName(boss, pit:GetAbsOrigin(), true, nil, nil, DOTA_TEAM_NEUTRALS)

DebugPrint(pit:GetAbsOrigin().x)
DebugPrint(pit:GetAbsOrigin().y)

local team = DOTA_TEAM_GOODGUYS
if pit:GetAbsOrigin().x > 0 then
team = DOTA_TEAM_BADGUYS
end

if pit:GetAbsOrigin().y > 5000 then
team = DOTA_TEAM_GOODGUYS
elseif pit:GetAbsOrigin().y < -5000 then
team = DOTA_TEAM_BADGUYS
end

DebugPrint('Boss natively belongs to ' .. team)

local bossPrefix = string.sub(boss, 0, 19)
DebugPrint('boss name ' .. bossPrefix)

Expand All @@ -59,7 +106,9 @@ function BossSpawner:SpawnBoss (pit, boss, bossTier)

local bossAI = BossAI:Create(bossHandle, {
tier = bossTier,
customAgro = bossPrefix ~= 'npc_dota_boss_tier_'
customAgro = bossPrefix ~= 'npc_dota_boss_tier_',
owner = team,
isProtected = isProtected
})

local newBossTier = math.min(6, bossTier + 1)
Expand Down

0 comments on commit 4181001

Please sign in to comment.