Skip to content

Commit

Permalink
Random fixes (#556)
Browse files Browse the repository at this point in the history
* Fix duels being dumb and super enforce zones

* Fix zone control, fix duel zones, fix double respawn

* Languages
  • Loading branch information
chrisinajar authored Apr 15, 2017
1 parent f19a269 commit 5c14ce2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 20 deletions.
Binary file modified content/maps/oaa.vmap
Binary file not shown.
Binary file modified content/materials/overviews/oaa.tga
Binary file not shown.
Binary file modified game/resource/addon_english.txt
Binary file not shown.
Binary file modified game/resource/addon_german.txt
Binary file not shown.
Binary file modified game/resource/addon_portuguese.txt
Binary file not shown.
Binary file modified game/resource/addon_russian.txt
Binary file not shown.
28 changes: 11 additions & 17 deletions game/scripts/vscripts/components/duels/duels.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ function Duels:Init ()
Duels.currentDuel = nil
Duels.zone1 = ZoneControl:CreateZone('duel_1', {
mode = ZONE_CONTROL_INCLUSIVE,
margin = 200,
margin = 500,
padding = 200,
players = {
}
})

Duels.zone2 = ZoneControl:CreateZone('duel_2', {
mode = ZONE_CONTROL_INCLUSIVE,
margin = 200,
margin = 500,
padding = 200,
players = {
}
})
Expand Down Expand Up @@ -275,16 +277,6 @@ function Duels:EndDuel ()
for playerId = 0,19 do
Duels.zone1.removePlayer(playerId, false)
Duels.zone2.removePlayer(playerId, false)
local player = PlayerResource:GetPlayer(playerId)
if player ~= nil and player:GetAssignedHero() then
local hero = player:GetAssignedHero()
if hero then
hero:SetRespawnsDisabled(false)
if not hero:IsAlive() then
hero:RespawnHero(false,false,false)
end
end
end
end

local currentDuel = Duels.currentDuel
Expand All @@ -296,11 +288,15 @@ function Duels:EndDuel ()
DebugPrint('Is this a player id? ' .. state.id)
local player = PlayerResource:GetPlayer(state.id)
local hero = player:GetAssignedHero()
hero:SetRespawnsDisabled(false)
if not hero:IsAlive() then
hero:SetRespawnsDisabled(false)
hero:RespawnHero(false,false,false)
end

if not state.assigned then
return
end

Duels:RestorePlayerState (hero, state)
Duels:MoveCameraToPlayer(state.id, hero)
end)
Expand Down Expand Up @@ -336,7 +332,6 @@ function Duels:SavePlayerState (hero)
local state = {
location = hero:GetAbsOrigin(),
abilityCount = hero:GetAbilityCount(),
maxAbility = 0,
abilities = {},
items = {},
hp = hero:GetHealth(),
Expand All @@ -352,10 +347,9 @@ function Duels:SavePlayerState (hero)
end
end

for abilityIndex = 0,state.abilityCount-1 do
for abilityIndex = 0,hero:GetAbilityCount()-1 do
local ability = hero:GetAbilityByIndex(abilityIndex)
if ability ~= nil then
state.maxAbility = abilityIndex
state.abilities[abilityIndex] = {
cooldown = ability:GetCooldownTimeRemaining()
}
Expand All @@ -381,7 +375,7 @@ function Duels:RestorePlayerState (hero, state)
end
hero:SetMana(state.mana)

for abilityIndex = 0,state.maxAbility-1 do
for abilityIndex = 0,hero:GetAbilityCount()-1 do
local ability = hero:GetAbilityByIndex(abilityIndex)
if ability ~= nil then
ability:StartCooldown(state.abilities[abilityIndex].cooldown)
Expand Down
11 changes: 8 additions & 3 deletions game/scripts/vscripts/components/zonecontrol/zones.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ function ZoneControl:CreateStateFromHandle (handle, options)
handle:RedirectOutput('OnStartTouch', 'startTouchHandler', handle)
handle:RedirectOutput('OnEndTouch', 'endTouchHandler', handle)

Timers:CreateTimer(5, function ()
ZoneControl:EnforceRules(state)
return 5
end)

return state;
end

Expand Down Expand Up @@ -214,7 +219,7 @@ end
function ZoneControl:EnforceRulesOnPlayerId (state, playerId)
local player = PlayerResource:GetPlayer(playerId)

if player then
if player and player:GetAssignedHero() then
ZoneControl:EnforceRulesOnEntity(state, playerId, player:GetAssignedHero())
end
end
Expand Down Expand Up @@ -300,9 +305,9 @@ function ZoneControl:EnforceRulesOnEntity (state, playerId, entity)
local x = origin.x
local y = origin.y
local topWall = state.origin.y + state.bounds.Maxs.y - state.padding
local rightWall = state.origin.x + state.bounds.Maxs.x + state.padding
local rightWall = state.origin.x + state.bounds.Maxs.x - state.padding
local bottomWall = state.origin.y + state.bounds.Mins.y + state.padding
local leftWall = state.origin.x + state.bounds.Mins.x - state.padding
local leftWall = state.origin.x + state.bounds.Mins.x + state.padding

if x > rightWall then
x = rightWall
Expand Down

0 comments on commit 5c14ce2

Please sign in to comment.