- 15 Мар 2016
- 1,335
- 105
В общем мне нужно вот что: Юнит убивает крипа(слушатель уже есть) затем создается(либо уже в созданную) переменная, в которую добавляется +1.
Но дело в том, что нужно, чтобы у каждого героя эта переменная была своя и для каждого крипа тоже.
Что то наподобие id.killedEntity, тоесть PlayerOwnerId и имя крипа.
Вот код, в котором, я пытаюсь что то похожее сделать:
Но дело в том, что нужно, чтобы у каждого героя эта переменная была своя и для каждого крипа тоже.
Что то наподобие id.killedEntity, тоесть PlayerOwnerId и имя крипа.
Вот код, в котором, я пытаюсь что то похожее сделать:
Код:
function GameMode:OnEntityKilled( keys )
print( '[BAREBONES] OnEntityKilled Called' )
DeepPrintTable( keys )
-- The Unit that was Killed
local killedUnit = EntIndexToHScript( keys.entindex_killed )
-- The Killing entity
local killerEntity = nil
local killedTeam = killedUnit:GetTeam()
if keys.entindex_attacker ~= nil then
killerEntity = EntIndexToHScript( keys.entindex_attacker )
end
local killerTeam = killerEntity:GetTeam()
local id = killerEntity
--[[ id.runner_simple = 0 Что то наподобие вот такого должно быть или как?
id.fly_simple = 0
id.tank_simple = 0
id.attacker_simple = 0
id.guard_simple = 0
id.hitter_simple = 0]]
print("FLY SIMPLE " .. id.fly_simple)
if killedUnit:IsCreature() then
local name = killedUnit:GetUnitName()
print("NAME KILLED UNIT IS: " .. name)
local modifier = tostring("modifier_" .. name .. "_mut")
if not killerEntity:HasModifier(modifier) then
killerEntity:AddNewModifier(killerEntity,nil,modifier,{})
end
local current_stack = killerEntity:GetModifierStackCount(modifier,killerEntity)
killerEntity:SetModifierStackCount(modifier,killerEntity,current_stack + 1)
if name == fly_simple then
id.fly_simple = id.fly_simple + 1
elseif name == runner_simple then
id.runner_simple = id.runner_simple + 1
end
if modifier == "modifier_runner_simple_mut" then
id.runner_simple = id.runner_simple + 1
if id.runner_simple >= 100 then
id.runner_simple = 100
end
if current_stack >= 100 then
killerEntity:SetModifierStackCount("modifier_runner_simple_mut", killerEntity, 100)
end
end
if modifier == "modifier_fly_simple_mut" then
id.fly_simple = id.fly_simple + 1
if id.fly_simple >= 320 then
id.fly_simple = 320
end
if current_stack >= 320 then
killerEntity:SetModifierStackCount("modifier_fly_simple_mut", killerEntity, 320)
end
end
if modifier == "modifier_tank_simple_mut" then
id.tank_simple = id.tank_simple + 1
if id.tank_simple >= 220 then
id.tank_simple = 220
end
if current_stack >= 220 then
killerEntity:SetModifierStackCount("modifier_tank_simple_mut", killerEntity, 220)
end
end
if modifier == "modifier_attacker_simple_mut" then
id.attacker_simple = id.attacker_simple + 1
if id.attacker_simple >= 200 then
id.attacker_simple = 200
end
if current_stack >= 200 then
killerEntity:SetModifierStackCount("modifier_attacker_simple_mut", killerEntity, 200)
end
end
if modifier == "modifier_guard_simple_mut" then
id.guard_simple = id.guard_simple + 1
if id.guard_simple >= 25 then
id.guard_simple = 25
end
if current_stack >= 25 then
killerEntity:SetModifierStackCount("modifier_guard_simple_mut", killerEntity, 25)
end
end
if modifier == "modifier_hitter_simple_mut" then
id.hitter_simple = id.hitter_simple + 1
if id.hitter_simple >= 102 then
id.hitter_simple = 102
end
if current_stack >= 102 then
killerEntity:SetModifierStackCount("modifier_hitter_simple_mut", killerEntity, 102)
end
end
end
end
Последнее редактирование модератором: