hi,
i have desync problems with one of my custom resurrection abilitys. If any player uses this ability, everyone gets kicket out (no error messege) to the score board. This ability works fine in single player. The desync happen on cast.
My lua code with some comments, is below.
Thanks in advance
i have desync problems with one of my custom resurrection abilitys. If any player uses this ability, everyone gets kicket out (no error messege) to the score board. This ability works fine in single player. The desync happen on cast.
My lua code with some comments, is below.
Thanks in advance
JASS:
function ReviveClass:Execute(info)
//get death units
local deathUnits = UnitClass.GetDeathInRange(self.radius, info.targetLoc)
local count = 0
for _, v in pairs(deathUnits) do
local loc = GetUnitLoc(v)
local id = GetUnitTypeId(v)
local typeObj = UnitTypeClass.UNITS[GetUnitTypeId(v)] //table with information if its a hero, building and much more
local orderble = typeObj:CanGetOrder() //simple boolean check if its a hero, building ...
//if its not a building ... create a new one (same type) and delete the corpse
if orderble then
//UnitClass.NewUnit ... Create a unit and store in a table with some information
//Im using this a lot, so it shouldn be the problem
local unitObj = UnitClass.NewUnit(units[info.unit],loc,id)
RemoveUnit(v)
RemoveLocation(loc)
count = count + 1
//resurrect max 2 units
if count >= self.max then break end //max=2
end
end
//create an effect at location for 4.5 sec
CreateEffectLoc(4.5,info.targetLoc,"Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl")
end
UnitClass.GetDeathInRange = function(radius, loc)
local death = {}
local g = GetUnitsInRangeOfLocAll(radius, loc)
local u = FirstOfGroup(g)
while u ~= nil do
if IsUnitAliveBJ(u) == false then
death[u]=u
end
GroupRemoveUnit(g, u)
u = FirstOfGroup(g)
end
DestroyGroup(g)
return death
end
function CreateEffectLoc(duration,loc,model)
local ExpiredFunc = function()
local t = timers[GetExpiredTimer()]
local e = t.arg[1]
BlzSetSpecialEffectPosition(e,0, 0, 1000)
DestroyEffectBJ(e)
t:Remove()
end
local effect = AddSpecialEffectLoc(model, loc)
TimerClass:Create(duration,false,ExpiredFunc,effect)
end
//Im using this timer a ton, so it shouldn be the problem
timers = {}
TimerClass = {}
function TimerClass:Create(duration,isPeriodic,ExpiredFunc,...)
local this = {}
this.this = CreateTimer()
this.duration = duration
this.isPeriodic = isPeriodic
this.ExpiredFunc = ExpiredFunc
this.arg = {...}
self.__index = self
setmetatable(this, self)
timers[this.this] = this
TimerStart(this.this, duration, isPeriodic, this.ExpiredFunc)
return this
end
function TimerClass:Remove()
if self.isPeriodic == false then
DestroyTimer(self.this)
timers[self] = nil
end
end
Last edited: