Skip to content

Commit 67b8bd9

Browse files
Chronophyloschrisinajar
authored andcommitted
Fixing bugs (#743)
* Saving modifiers * Let's not use this file * Fixed neutral kills counting as hero kills * Fix not tping at start if the duel when casting abilities * Revert "saving modifiers" * Actuall use lenghtr
1 parent aca067c commit 67b8bd9

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

game/scripts/vscripts/components/duels/duels.lua

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ function Duels:Init ()
4343
Duels:CheckDuelStatus(keys)
4444
end)
4545

46+
GameEvents:OnPlayerReconnect(function (keys)
47+
local playerID = keys.playerID
48+
if playerID then
49+
local hero = PlayerResource:GetSelectedHeroEntity(playerID)
50+
if not Duels.currentDuel then
51+
hero:SetRespawnsDisabled(false)
52+
if not hero:IsAlive() then
53+
hero:RespawnHero(false, false, false)
54+
end
55+
end
56+
end
57+
end)
58+
4659
Timers:CreateTimer(1, function ()
4760
Duels:StartDuel()
4861
end)
@@ -180,8 +193,11 @@ function Duels:ActuallyStartDuel ()
180193
goodGuy.duelNumber = 1
181194
badGuy.duelNumber = 1
182195

183-
FindClearSpaceForUnit(goodHero, spawn1, true)
184-
FindClearSpaceForUnit(badHero, spawn2, true)
196+
self:SafeTeleport(goodHero, spawn1, 150)
197+
self:SafeTeleport(badHero, spawn2, 150)
198+
--FindClearSpaceForUnit(goodHero, spawn1, true)
199+
--FindClearSpaceForUnit(badHero, spawn2, true)
200+
185201

186202
Duels.zone1.addPlayer(goodGuy.id)
187203
Duels.zone1.addPlayer(badGuy.id)
@@ -326,15 +342,15 @@ function Duels:ResetPlayerState (hero)
326342
hero:SetMana(hero:GetMaxMana())
327343

328344
-- Reset cooldown for abilities
329-
for abilityIndex = 0,hero:GetAbilityCount() - 1 do
345+
for abilityIndex = 0, hero:GetAbilityCount() - 1 do
330346
local ability = hero:GetAbilityByIndex(abilityIndex)
331347
if ability ~= nil then
332348
ability:EndCooldown()
333349
end
334350
end
335351

336352
-- Reset cooldown for items
337-
for i = 0, 5 do
353+
for i = DOTA_ITEM_SLOT_1, DOTA_ITEM_SLOT_6 do
338354
local item = hero:GetItemInSlot(i)
339355
if item then
340356
item:EndCooldown()
@@ -348,6 +364,7 @@ function Duels:SavePlayerState (hero)
348364
abilityCount = hero:GetAbilityCount(),
349365
abilities = {},
350366
items = {},
367+
modifiers = {},
351368
hp = hero:GetHealth(),
352369
mana = hero:GetMana()
353370
}
@@ -370,15 +387,14 @@ function Duels:SavePlayerState (hero)
370387
end
371388
end
372389

373-
for itemIndex = 0,5 do
390+
for itemIndex = DOTA_ITEM_SLOT_1, DOTA_ITEM_SLOT_6 do
374391
local item = hero:GetItemInSlot(itemIndex)
375392
if item ~= nil then
376393
state.items[itemIndex] = {
377394
cooldown = item:GetCooldownTimeRemaining()
378395
}
379396
end
380397
end
381-
382398
return state
383399
end
384400

@@ -389,7 +405,7 @@ function Duels:RestorePlayerState (hero, state)
389405
end
390406
hero:SetMana(state.mana)
391407

392-
for abilityIndex = 0,hero:GetAbilityCount()-1 do
408+
for abilityIndex = 0, hero:GetAbilityCount() - 1 do
393409
local ability = hero:GetAbilityByIndex(abilityIndex)
394410
if ability ~= nil then
395411
if state.abilities[abilityIndex] == nil then
@@ -401,7 +417,7 @@ function Duels:RestorePlayerState (hero, state)
401417
end
402418
end
403419

404-
for itemIndex = 0,5 do
420+
for itemIndex = DOTA_ITEM_SLOT_1, DOTA_ITEM_SLOT_6 do
405421
local item = hero:GetItemInSlot(itemIndex)
406422
if item ~= nil and state.items[itemIndex] then
407423
item:StartCooldown(state.items[itemIndex].cooldown)
@@ -430,3 +446,13 @@ function Duels:AllPlayers (state, cb)
430446
end
431447
end
432448
end
449+
450+
function Duels:SafeTeleport(unit, location, maxDistance)
451+
FindClearSpaceForUnit(unit, location, true)
452+
local distance = (location - unit:GetAbsOrigin()):Length2D()
453+
if distance > maxDistance then
454+
Timers:CreateTimer(0.1, function()
455+
self:SafeTeleport(unit, location, maxDistance)
456+
end)
457+
end
458+
end

game/scripts/vscripts/components/points/points.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function PointsManager:Init ()
1818

1919
GameEvents:OnHeroKilled(function (keys)
2020
-- increment points
21-
if keys.killer:GetTeam() ~= keys.killed:GetTeam() and not keys.killed:IsReincarnating() then
21+
if keys.killer:GetTeam() ~= keys.killed:GetTeam() and not keys.killed:IsReincarnating() and keys.killed:GetTeam() ~= DOTA_TEAM_NEUTRALS then
2222
self:AddPoints(keys.killer:GetTeam())
2323
end
2424
end)

game/scripts/vscripts/events.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,6 @@ function GameMode:OnPlayerReconnect(keys)
114114
return
115115
end
116116

117-
local hero = PlayerResource:GetSelectedHeroEntity(playID)
118-
if not Duels.currentDuel then
119-
hero:SetRespawnsDisabled(false)
120-
if not hero:IsAlive() then
121-
hero:RespawnHero(false,false,false)
122-
end
123-
end
124117
end
125118

126119
-- An item was purchased by a player

0 commit comments

Comments
 (0)