@@ -111,22 +111,24 @@ function Duels:ActuallyStartDuel ()
111
111
local player = PlayerResource :GetPlayer (playerId )
112
112
if player ~= nil then
113
113
DebugPrint (' Players team ' .. player :GetTeam ())
114
- if player :GetTeam () == 3 then
115
- badPlayers [badPlayerIndex ] = Duels :SavePlayerState (player :GetAssignedHero ())
116
- badPlayers [badPlayerIndex ].id = playerId
117
- -- used to generate keynames like badEnd1
118
- -- not used in dota apis
119
- badPlayers [badPlayerIndex ].team = ' bad'
120
- badPlayerIndex = badPlayerIndex + 1
121
-
122
- elseif player :GetTeam () == 2 then
123
- goodPlayers [goodPlayerIndex ] = Duels :SavePlayerState (player :GetAssignedHero ())
124
- goodPlayers [goodPlayerIndex ].id = playerId
125
- goodPlayers [goodPlayerIndex ].team = ' good'
126
- goodPlayerIndex = goodPlayerIndex + 1
114
+ if player :GetAssignedHero () then
115
+ if player :GetTeam () == 3 then
116
+ badPlayers [badPlayerIndex ] = Duels :SavePlayerState (player :GetAssignedHero ())
117
+ badPlayers [badPlayerIndex ].id = playerId
118
+ -- used to generate keynames like badEnd1
119
+ -- not used in dota apis
120
+ badPlayers [badPlayerIndex ].team = ' bad'
121
+ badPlayerIndex = badPlayerIndex + 1
122
+
123
+ elseif player :GetTeam () == 2 then
124
+ goodPlayers [goodPlayerIndex ] = Duels :SavePlayerState (player :GetAssignedHero ())
125
+ goodPlayers [goodPlayerIndex ].id = playerId
126
+ goodPlayers [goodPlayerIndex ].team = ' good'
127
+ goodPlayerIndex = goodPlayerIndex + 1
128
+ end
129
+
130
+ Duels :ResetPlayerState (player :GetAssignedHero ())
127
131
end
128
-
129
- Duels :ResetPlayerState (player :GetAssignedHero ())
130
132
end
131
133
end
132
134
@@ -270,8 +272,14 @@ function Duels:EndDuel ()
270
272
Duels .zone1 .removePlayer (playerId )
271
273
Duels .zone2 .removePlayer (playerId )
272
274
local player = PlayerResource :GetPlayer (playerId )
273
- if player ~= nil then
274
- player :GetAssignedHero ():SetRespawnsDisabled (false )
275
+ if player ~= nil and player :GetAssignedHero () then
276
+ local hero = player :GetAssignedHero ()
277
+ if hero then
278
+ hero :SetRespawnsDisabled (false )
279
+ if not hero :IsAlive () then
280
+ hero :RespawnHero (false ,false ,false )
281
+ end
282
+ end
275
283
end
276
284
end
277
285
@@ -304,7 +312,7 @@ function Duels:ResetPlayerState (hero)
304
312
hero :SetMana (hero :GetMaxMana ())
305
313
306
314
-- Reset cooldown for abilities
307
- for abilityIndex = 0 ,hero :GetAbilityCount () do
315
+ for abilityIndex = 0 ,hero :GetAbilityCount () - 1 do
308
316
local ability = hero :GetAbilityByIndex (abilityIndex )
309
317
if ability ~= nil then
310
318
ability :EndCooldown ()
0 commit comments